summaryrefslogtreecommitdiff
path: root/apps/app_parkandannounce.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2011-12-16 01:29:20 +0000
committerRichard Mudgett <rmudgett@digium.com>2011-12-16 01:29:20 +0000
commit8baea2b35e96d1c51756c00aff322a4e1af858a0 (patch)
treeff6402a1315f332c989873fc132de26446a695f5 /apps/app_parkandannounce.c
parent7a3bda0ce39be5c26a9b73d4402cd19419a31804 (diff)
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. ........ Merged revisions 348310 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 348311 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@348312 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_parkandannounce.c')
-rw-r--r--apps/app_parkandannounce.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/apps/app_parkandannounce.c b/apps/app_parkandannounce.c
index 7338efb98..c899bd220 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, };
@@ -110,7 +111,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");
res = -1;
goto parkcleanup;
}
@@ -148,17 +149,24 @@ 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);
res = -1;
goto parkcleanup;
}
- 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 */
@@ -167,9 +175,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, cap_slin, 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);
@@ -209,7 +219,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;
}
}
}