From: Richard Mudgett Date: Fri, 16 Dec 2011 01:21:56 +0000 (+0000) Subject: Fix ParkAndAnnounce to pass the CallerID to the announcing channel. X-Git-Tag: 1.8.9.0-rc1~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b17e5e23c49fba1cfb5f4ea521fb633dfaa821a;p=thirdparty%2Fasterisk.git Fix ParkAndAnnounce to pass the CallerID to the announcing channel. ParkAndAnnounce tried to pass the CallerID to the announcing channel but the ID was wiped out by the channel masquerade done when parking the call. * Save the CallerID before parking the channel to pass it to the announcing channel. * Fixed a minor memory leak in ParkAndAnnounce. * Updated some ParkAndAnnounce log messages. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@348310 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/apps/app_parkandannounce.c b/apps/app_parkandannounce.c index b04424ad50..cb11f26d17 100644 --- a/apps/app_parkandannounce.c +++ b/apps/app_parkandannounce.c @@ -96,6 +96,7 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data) char *dialtech, *tmp[100], buf[13]; int looptemp, i; char *s; + struct ast_party_id caller_id; struct ast_channel *dchan; struct outgoing_helper oh = { 0, }; @@ -107,7 +108,7 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data) AST_APP_ARG(return_context); ); if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "ParkAndAnnounce requires arguments: (announce:template|timeout|dial|[return_context])\n"); + ast_log(LOG_WARNING, "ParkAndAnnounce requires arguments: (announce_template,timeout,dial,[return_context])\n"); return -1; } @@ -138,16 +139,23 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data) ast_verb(3, "Warning: Return Context Invalid, call will return to default|s\n"); } + /* Save the CallerID because the masquerade turns chan into a ZOMBIE. */ + ast_channel_lock(chan); + ast_party_id_copy(&caller_id, &chan->caller.id); + ast_channel_unlock(chan); + /* we are using masq_park here to protect * from touching the channel once we park it. If the channel comes out of timeout before we are done announcing and the channel is messed with, Kablooeee. So we use Masq to prevent this. */ res = ast_masq_park_call(chan, NULL, timeout, &lot); if (res) { /* Parking failed. */ + ast_party_id_free(&caller_id); return -1; } - ast_verb(3, "Call Parking Called, lot: %d, timeout: %d, context: %s\n", lot, timeout, args.return_context); + ast_verb(3, "Call parked in space: %d, timeout: %d, return-context: %s\n", + lot, timeout, args.return_context ? args.return_context : ""); /* Now place the call to the extension */ @@ -156,9 +164,11 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data) oh.vars = ast_variable_new("_PARKEDAT", buf, ""); dchan = __ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, chan, args.dial, 30000, &outstate, - S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL), - S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL), + S_COR(caller_id.number.valid, caller_id.number.str, NULL), + S_COR(caller_id.name.valid, caller_id.name.str, NULL), &oh); + ast_variables_destroy(oh.vars); + ast_party_id_free(&caller_id); if (dchan) { if (dchan->_state == AST_STATE_UP) { ast_verb(4, "Channel %s was answered.\n", dchan->name); @@ -196,7 +206,6 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data) dres = ast_waitstream(dchan, ""); } else { ast_log(LOG_WARNING, "ast_streamfile of %s failed on %s\n", tmp[i], dchan->name); - dres = 0; } } }