[svn-commits] jpeeler: branch 1.6.1 r146886 - in /branches/1.6.1: ./ main/features.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Oct 6 17:26:48 CDT 2008


Author: jpeeler
Date: Mon Oct  6 17:26:47 2008
New Revision: 146886

URL: http://svn.digium.com/view/asterisk?view=rev&rev=146886
Log:
Merged revisions 146883 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r146883 | jpeeler | 2008-10-06 17:26:25 -0500 (Mon, 06 Oct 2008) | 12 lines

This commit squashes together three commits because the wrong approach was originally used. (One of the commits was only one line.)

1) r143204:
The main change here was to masquerade the channel if the channel that was to be parked was running a PBX on it. The PBX thread can then maintain full control of the channel (the zombie) as it expects to while allowing the parking thread full control of the real (parked) channel.

2) r143270:
Changed park_call_full to hold the parkinglot lock a little longer, which protects the parkeduser struct from being freed out from underneath. Made sure that the parking extension is added to the parking context while holding the lock thereby ensuring that there are no spurious warnings from removal attempts when a hangup occurs while the parking lot is being announced.

3) r143475: (the one liner)
compare peer and chan instead of looking at the parked user (pu), which could have possibly already have been freed by the parking thread


........

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/main/features.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.1/main/features.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/main/features.c?view=diff&rev=146886&r1=146885&r2=146886
==============================================================================
--- branches/1.6.1/main/features.c (original)
+++ branches/1.6.1/main/features.c Mon Oct  6 17:26:47 2008
@@ -456,7 +456,7 @@
 	struct ast_park_call_args *args)
 {
 	struct parkeduser *pu;
-	int i, x = -1, parking_range;
+	int i, x = -1, parking_range, parkingnum_copy;
 	struct ast_context *con;
 	const char *parkinglotname = NULL;
 	const char *parkingexten;
@@ -574,6 +574,7 @@
 	pu->parkingnum = x;
 	pu->parkinglot = parkinglot;
 	pu->parkingtime = (args->timeout > 0) ? args->timeout : parkinglot->parkingtime;
+	parkingnum_copy = pu->parkingnum;
 	if (args->extout)
 		*(args->extout) = x;
 
@@ -596,8 +597,6 @@
 	/* If parking a channel directly, don't quiet yet get parking running on it */
 	if (peer == chan) 
 		pu->notquiteyet = 1;
-	AST_LIST_UNLOCK(&parkinglot->parkings);
-
 
 	/* Wake up the (presumably select()ing) thread */
 	pthread_kill(parking_thread, SIGURG);
@@ -627,6 +626,13 @@
 	con = ast_context_find_or_create(NULL, NULL, parkinglot->parking_con, registrar);
 	if (!con)	/* Still no context? Bad */
 		ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parkinglot->parking_con);
+	if (con) {
+		if (!ast_add_extension2(con, 1, pu->parkingexten, 1, NULL, NULL, parkedcall, ast_strdup(pu->parkingexten), ast_free_ptr, registrar))
+			notify_metermaids(pu->parkingexten, parkinglot->parking_con, AST_DEVICE_INUSE);
+	}
+
+	AST_LIST_UNLOCK(&parkinglot->parkings);
+
 	/* Only say number if it's a number and the channel hasn't been masqueraded away */
 	if (peer && !ast_test_flag(args, AST_PARK_OPT_SILENCE) && (ast_strlen_zero(args->orig_chan_name) || !strcasecmp(peer->name, args->orig_chan_name))) {
 		/* If a channel is masqueraded into peer while playing back the parking slot number do not continue playing it back. This is the case if an attended transfer occurs. */
@@ -635,11 +641,7 @@
 		ast_say_digits(peer, pu->parkingnum, "", peer->language);
 		ast_clear_flag(peer, AST_FLAG_MASQ_NOSTREAM);
 	}
-	if (con) {
-		if (!ast_add_extension2(con, 1, pu->parkingexten, 1, NULL, NULL, parkedcall, ast_strdup(pu->parkingexten), ast_free_ptr, registrar))
-			notify_metermaids(pu->parkingexten, parkinglot->parking_con, AST_DEVICE_INUSE);
-	}
-	if (pu->notquiteyet) {
+	if (peer == chan) { /* pu->notquiteyet = 1 */
 		/* Wake up parking thread if we're really done */
 		ast_indicate_data(pu->chan, AST_CONTROL_HOLD, 
 			S_OR(parkinglot->mohclass, NULL),
@@ -661,8 +663,7 @@
 	return ast_park_call_full(chan, peer, &args);
 }
 
-/* Park call via masquraded channel */
-int ast_masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, int timeout, int *extout)
+static int masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, int timeout, int *extout, int play_announcement)
 {
 	struct ast_channel *chan;
 	struct ast_frame *f;
@@ -687,7 +688,9 @@
 	if ((f = ast_read(chan)))
 		ast_frfree(f);
 
-	orig_chan_name = ast_strdupa(chan->name);
+	if (!play_announcement) {
+		orig_chan_name = ast_strdupa(chan->name);
+	}
 
 	{
 		struct ast_park_call_args args = {
@@ -706,6 +709,18 @@
 
 	return 0;
 }
+
+/* Park call via masquraded channel */
+int ast_masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, int timeout, int *extout)
+{
+	return masq_park_call(rchan, peer, timeout, extout, 0);
+}
+
+static int masq_park_call_announce(struct ast_channel *rchan, struct ast_channel *peer, int timeout, int *extout)
+{
+	return masq_park_call(rchan, peer, timeout, extout, 1);
+}
+
 
 
 #define FEATURE_SENSE_CHAN	(1 << 0)
@@ -756,15 +771,23 @@
 		res = ast_answer(chan);
 	if (!res)
 		res = ast_safe_sleep(chan, 1000);
-	if (!res)
-		res = ast_park_call(parkee, parker, 0, NULL);
 
 	if (!res) {
-		if (sense == FEATURE_SENSE_CHAN)
-			res = AST_PBX_NO_HANGUP_PEER;
-		else
-			res = AST_PBX_KEEPALIVE;
-	}
+		if (sense == FEATURE_SENSE_CHAN) {
+			res = ast_park_call(parkee, parker, 0, NULL);
+			if (!res) {
+				if (sense == FEATURE_SENSE_CHAN) {
+					res = AST_PBX_NO_HANGUP_PEER;
+				} else {
+					res = AST_PBX_KEEPALIVE;
+				}
+			}
+		} else if (sense == FEATURE_SENSE_PEER) {
+			masq_park_call_announce(parkee, parker, 0, NULL);
+			res = 0; /* PBX should hangup zombie channel */
+		}
+	}
+
 	return res;
 
 }




More information about the svn-commits mailing list