Modify fix for issue 16554 to be more inline with what is already in trunk.

I should have taken a closer look at trunk/1.6.x, as this bug has already been
fixed in a much more simple manner, by just settings o->vars to NULL after the
ast_pbx_outgoing_* calls.

(issue #16554)
Reported by: mav3rick


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@241544 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Sean Bright 16 years ago
parent 0f6892b1a8
commit fd6b867c14

@ -122,9 +122,9 @@ static void init_outgoing(struct outgoing *o)
ast_set_flag(&o->options, SPOOL_FLAG_ALWAYS_DELETE); ast_set_flag(&o->options, SPOOL_FLAG_ALWAYS_DELETE);
} }
static void free_outgoing(struct outgoing *o, int free_vars) static void free_outgoing(struct outgoing *o)
{ {
if (free_vars && o->vars) { if (o->vars) {
ast_variables_destroy(o->vars); ast_variables_destroy(o->vars);
} }
free(o); free(o);
@ -355,6 +355,7 @@ static void *attempt_thread(void *data)
ast_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for %s@%s:%d (Retry %d)\n", o->tech, o->dest, o->exten, o->context,o->priority, o->retries); ast_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for %s@%s:%d (Retry %d)\n", o->tech, o->dest, o->exten, o->context,o->priority, o->retries);
res = ast_pbx_outgoing_exten(o->tech, o->format, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL); res = ast_pbx_outgoing_exten(o->tech, o->format, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL);
} }
o->vars = NULL;
if (res) { if (res) {
ast_log(LOG_NOTICE, "Call failed to go through, reason (%d) %s\n", reason, ast_channel_reason2str(reason)); ast_log(LOG_NOTICE, "Call failed to go through, reason (%d) %s\n", reason, ast_channel_reason2str(reason));
if (o->retries >= o->maxretries + 1) { if (o->retries >= o->maxretries + 1) {
@ -370,7 +371,7 @@ static void *attempt_thread(void *data)
ast_log(LOG_EVENT, "Queued call to %s/%s completed\n", o->tech, o->dest); ast_log(LOG_EVENT, "Queued call to %s/%s completed\n", o->tech, o->dest);
remove_from_queue(o, "Completed"); remove_from_queue(o, "Completed");
} }
free_outgoing(o, 0); free_outgoing(o);
return NULL; return NULL;
} }
@ -383,7 +384,7 @@ static void launch_service(struct outgoing *o)
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if ((ret = ast_pthread_create(&t,&attr,attempt_thread, o)) != 0) { if ((ret = ast_pthread_create(&t,&attr,attempt_thread, o)) != 0) {
ast_log(LOG_WARNING, "Unable to create thread :( (returned error: %d)\n", ret); ast_log(LOG_WARNING, "Unable to create thread :( (returned error: %d)\n", ret);
free_outgoing(o, 1); free_outgoing(o);
} }
pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
} }
@ -407,7 +408,7 @@ static int scan_service(char *fn, time_t now, time_t atime)
if (o->callingpid && (o->callingpid == ast_mainpid)) { if (o->callingpid && (o->callingpid == ast_mainpid)) {
safe_append(o, time(NULL), "DelayedRetry"); safe_append(o, time(NULL), "DelayedRetry");
ast_log(LOG_DEBUG, "Delaying retry since we're currently running '%s'\n", o->fn); ast_log(LOG_DEBUG, "Delaying retry since we're currently running '%s'\n", o->fn);
free_outgoing(o, 1); free_outgoing(o);
} else { } else {
/* Increment retries */ /* Increment retries */
o->retries++; o->retries++;
@ -423,19 +424,19 @@ static int scan_service(char *fn, time_t now, time_t atime)
} else { } else {
ast_log(LOG_EVENT, "Queued call to %s/%s expired without completion after %d attempt%s\n", o->tech, o->dest, o->retries - 1, ((o->retries - 1) != 1) ? "s" : ""); ast_log(LOG_EVENT, "Queued call to %s/%s expired without completion after %d attempt%s\n", o->tech, o->dest, o->retries - 1, ((o->retries - 1) != 1) ? "s" : "");
remove_from_queue(o, "Expired"); remove_from_queue(o, "Expired");
free_outgoing(o, 1); free_outgoing(o);
return 0; return 0;
} }
} else { } else {
ast_log(LOG_WARNING, "Invalid file contents in %s, deleting\n", fn); ast_log(LOG_WARNING, "Invalid file contents in %s, deleting\n", fn);
fclose(f); fclose(f);
remove_from_queue(o, "Failed"); remove_from_queue(o, "Failed");
free_outgoing(o, 1); free_outgoing(o);
} }
} else { } else {
ast_log(LOG_WARNING, "Unable to open %s: %s, deleting\n", fn, strerror(errno)); ast_log(LOG_WARNING, "Unable to open %s: %s, deleting\n", fn, strerror(errno));
remove_from_queue(o, "Failed"); remove_from_queue(o, "Failed");
free_outgoing(o, 1); free_outgoing(o);
} }
} else } else
ast_log(LOG_WARNING, "Out of memory :(\n"); ast_log(LOG_WARNING, "Out of memory :(\n");

Loading…
Cancel
Save