[svn-commits] rmudgett: branch 1.8 r348310 - /branches/1.8/apps/app_parkandannounce.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Dec 15 19:21:59 CST 2011


Author: rmudgett
Date: Thu Dec 15 19:21:56 2011
New Revision: 348310

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=348310
Log:
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.

Modified:
    branches/1.8/apps/app_parkandannounce.c

Modified: branches/1.8/apps/app_parkandannounce.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/apps/app_parkandannounce.c?view=diff&rev=348310&r1=348309&r2=348310
==============================================================================
--- branches/1.8/apps/app_parkandannounce.c (original)
+++ branches/1.8/apps/app_parkandannounce.c Thu Dec 15 19:21:56 2011
@@ -96,6 +96,7 @@
 	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 @@
 		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 @@
 		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 @@
 	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 @@
 				dres = ast_waitstream(dchan, "");
 			} else {
 				ast_log(LOG_WARNING, "ast_streamfile of %s failed on %s\n", tmp[i], dchan->name);
-				dres = 0;
 			}
 		}
 	}




More information about the svn-commits mailing list