diff options
author | Sean Bright <sean.bright@gmail.com> | 2017-03-07 07:25:25 -0500 |
---|---|---|
committer | Sean Bright <sean.bright@gmail.com> | 2017-03-08 17:31:49 -0500 |
commit | bc2c66b594b3671e21ea8b446a811b026434e362 (patch) | |
tree | 77b237e5b06f7be15a9bb8aad92f27519cab10d9 /pbx | |
parent | 9cd1a754a9898dce9682d8a3ee3de1ed0537d0b3 (diff) |
pbx_spool: Set AST_OUTGOING_ATTEMPT variable on channel
Set a variable on the channel that indicates which attempt number we
are currently performing to allow for attempt-specific behavior.
ASTERISK-26568 #close
Reported by: Roman Shubovich
Change-Id: Iacd7e8d43b0ed5b6cb021c62f41f1a1f5733dd89
Diffstat (limited to 'pbx')
-rw-r--r-- | pbx/pbx_spool.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/pbx/pbx_spool.c b/pbx/pbx_spool.c index 0c6c401ce..644347fcb 100644 --- a/pbx/pbx_spool.c +++ b/pbx/pbx_spool.c @@ -161,6 +161,19 @@ static struct outgoing *new_outgoing(const char *fn) return o; } +static void append_variable(struct outgoing *o, const char *name, const char *value) +{ + struct ast_variable *var = ast_variable_new(name, value, o->fn); + + if (!var) { + return; + } + + /* Always insert at the end, because some people want to treat the spool + * file as a script */ + ast_variable_list_append(&o->vars, var); +} + static void parse_line(char *line, unsigned int lineno, struct outgoing *o) { char *c; @@ -261,20 +274,7 @@ static void parse_line(char *line, unsigned int lineno, struct outgoing *o) strsep(&c2, "="); if (c2) { - struct ast_variable *var = ast_variable_new(c, c2, o->fn); - - if (var) { - /* - * Always insert at the end, because some people - * want to treat the spool file as a script - */ - struct ast_variable **tail = &o->vars; - - while (*tail) { - tail = &(*tail)->next; - } - *tail = var; - } + append_variable(o, c, c2); } else { ast_log(LOG_WARNING, "Malformed \"%s\" argument. Should be \"%s: variable=value\"\n", line, line); } @@ -328,6 +328,11 @@ static int apply_outgoing(struct outgoing *o, FILE *f) "along with tech and dest in file %s\n", o->fn); return -1; } + + if (snprintf(buf, sizeof(buf), "%d", o->retries + 1) < sizeof(buf)) { + append_variable(o, "AST_OUTGOING_ATTEMPT", buf); + } + return 0; } |