[svn-commits] murf: branch murf/masqpark r154970 - in /team/murf/masqpark: apps/ include/as...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Nov 6 12:25:49 CST 2008


Author: murf
Date: Thu Nov  6 12:25:48 2008
New Revision: 154970

URL: http://svn.digium.com/view/asterisk?view=rev&rev=154970
Log:
The  changes so far. The idea is to use the masq_park_call
funcs instead of the park_call funcs.

I have not modified one call yet; still deliberating
over that; there is one problem with the pbx wanting
to execute the 's' exten in the one-touch case, both
when A parks B, and B parks A. All the other paths do
not have this problem.


Modified:
    team/murf/masqpark/apps/app_dial.c
    team/murf/masqpark/apps/app_queue.c
    team/murf/masqpark/include/asterisk/pbx.h
    team/murf/masqpark/res/res_features.c

Modified: team/murf/masqpark/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/murf/masqpark/apps/app_dial.c?view=diff&rev=154970&r1=154969&r2=154970
==============================================================================
--- team/murf/masqpark/apps/app_dial.c (original)
+++ team/murf/masqpark/apps/app_dial.c Thu Nov  6 12:25:48 2008
@@ -1821,35 +1821,28 @@
 			res = -1;
 		}
 
-		if (res != AST_PBX_NO_HANGUP_PEER && res != AST_PBX_NO_HANGUP_PEER_PARKED) {
-			if (res != AST_PBX_KEEPALIVE && !chan->_softhangup)
-				chan->hangupcause = peer->hangupcause;
-			ast_hangup(peer);
-		}
+		if (!chan->_softhangup)
+			chan->hangupcause = peer->hangupcause;
+		ast_hangup(peer);
 	}	
 out:
-	/* cleaning up chan is not a good idea here if AST_PBX_KEEPALIVE
-	   is returned; chan will get the love it needs from another
-	   thread */
-	if (res != AST_PBX_KEEPALIVE) {
-		if (moh) {
-			moh = 0;
-			ast_moh_stop(chan);
-		} else if (sentringing) {
-			sentringing = 0;
-			ast_indicate(chan, -1);
-		}
-		ast_rtp_early_bridge(chan, NULL);
-		hanguptree(outgoing, NULL);
-		pbx_builtin_setvar_helper(chan, "DIALSTATUS", status);
-		if (option_debug)
-			ast_log(LOG_DEBUG, "Exiting with DIALSTATUS=%s.\n", status);
-		
-		if ((ast_test_flag(peerflags, OPT_GO_ON)) && (!chan->_softhangup) && (res != AST_PBX_KEEPALIVE)) {
-			if (calldurationlimit)
-				chan->whentohangup = 0;
-			res = 0;
-		}
+	if (moh) {
+		moh = 0;
+		ast_moh_stop(chan);
+	} else if (sentringing) {
+		sentringing = 0;
+		ast_indicate(chan, -1);
+	}
+	ast_rtp_early_bridge(chan, NULL);
+	hanguptree(outgoing, NULL);
+	pbx_builtin_setvar_helper(chan, "DIALSTATUS", status);
+	if (option_debug)
+		ast_log(LOG_DEBUG, "Exiting with DIALSTATUS=%s.\n", status);
+	
+	if (ast_test_flag(peerflags, OPT_GO_ON) && !chan->_softhangup) {
+		if (calldurationlimit)
+			chan->whentohangup = 0;
+		res = 0;
 	}
 
 done:

Modified: team/murf/masqpark/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/murf/masqpark/apps/app_queue.c?view=diff&rev=154970&r1=154969&r2=154970
==============================================================================
--- team/murf/masqpark/apps/app_queue.c (original)
+++ team/murf/masqpark/apps/app_queue.c Thu Nov  6 12:25:48 2008
@@ -3153,7 +3153,7 @@
 		setup_transfer_datastore(qe, member, callstart, callcompletedinsl);
 		bridge = ast_bridge_call(qe->chan,peer, &bridge_config);
 
-		if (bridge != AST_PBX_KEEPALIVE && !attended_transfer_occurred(qe->chan)) {
+		if (!attended_transfer_occurred(qe->chan)) {
 			struct ast_datastore *transfer_ds;
 			if (strcasecmp(oldcontext, qe->chan->context) || strcasecmp(oldexten, qe->chan->exten)) {
 				ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "TRANSFER", "%s|%s|%ld|%ld",
@@ -3162,7 +3162,7 @@
 			} else if (qe->chan->_softhangup) {
 				ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "COMPLETECALLER", "%ld|%ld|%d",
 					(long) (callstart - qe->start), (long) (time(NULL) - callstart), qe->opos);
-				if (bridge != AST_PBX_NO_HANGUP_PEER && bridge != AST_PBX_NO_HANGUP_PEER_PARKED && qe->parent->eventwhencalled)
+				if (qe->parent->eventwhencalled)
 					manager_event(EVENT_FLAG_AGENT, "AgentComplete",
 							"Queue: %s\r\n"
 							"Uniqueid: %s\r\n"
@@ -3179,7 +3179,7 @@
 			} else {
 				ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "COMPLETEAGENT", "%ld|%ld|%d",
 					(long) (callstart - qe->start), (long) (time(NULL) - callstart), qe->opos);
-				if (bridge != AST_PBX_NO_HANGUP_PEER && bridge != AST_PBX_NO_HANGUP_PEER_PARKED && qe->parent->eventwhencalled)
+				if (qe->parent->eventwhencalled)
 					manager_event(EVENT_FLAG_AGENT, "AgentComplete",
 							"Queue: %s\r\n"
 							"Uniqueid: %s\r\n"
@@ -3203,8 +3203,7 @@
 			update_queue(qe->parent, member, callcompletedinsl);
 		}
 
-		if (bridge != AST_PBX_NO_HANGUP_PEER && bridge != AST_PBX_NO_HANGUP_PEER_PARKED)
-			ast_hangup(peer);
+		ast_hangup(peer);
 		res = bridge ? bridge : 1;
 		ao2_ref(member, -1);
 	}
@@ -4076,7 +4075,7 @@
 		}
 
 		/* Don't allow return code > 0 */
-		if (res >= 0 && res != AST_PBX_KEEPALIVE) {
+		if (res >= 0) {
 			res = 0;	
 			if (ringing) {
 				ast_indicate(chan, -1);

Modified: team/murf/masqpark/include/asterisk/pbx.h
URL: http://svn.digium.com/view/asterisk/team/murf/masqpark/include/asterisk/pbx.h?view=diff&rev=154970&r1=154969&r2=154970
==============================================================================
--- team/murf/masqpark/include/asterisk/pbx.h (original)
+++ team/murf/masqpark/include/asterisk/pbx.h Thu Nov  6 12:25:48 2008
@@ -38,8 +38,6 @@
 
 /*! \brief Special return values from applications to the PBX { */
 #define AST_PBX_KEEPALIVE               10	/*!< Destroy the thread, but don't hang up the channel */
-#define AST_PBX_NO_HANGUP_PEER	        11  /*!< The peer has been involved in a transfer */
-#define AST_PBX_NO_HANGUP_PEER_PARKED	12  /*!< Don't touch the peer channel - it was sent to the parking lot and might be gone by now */
 /*! } */
 
 #define PRIORITY_HINT	-1	/*!< Special Priority for a hint */

Modified: team/murf/masqpark/res/res_features.c
URL: http://svn.digium.com/view/asterisk/team/murf/masqpark/res/res_features.c?view=diff&rev=154970&r1=154969&r2=154970
==============================================================================
--- team/murf/masqpark/res/res_features.c (original)
+++ team/murf/masqpark/res/res_features.c Thu Nov  6 12:25:48 2008
@@ -535,12 +535,8 @@
 {
 	return masq_park_call(rchan, peer, timeout, extout, 1);
 }
-
 #define FEATURE_RETURN_HANGUP                  -1
 #define FEATURE_RETURN_SUCCESSBREAK             0
-#define FEATURE_RETURN_PBX_KEEPALIVE            AST_PBX_KEEPALIVE
-#define FEATURE_RETURN_NO_HANGUP_PEER           AST_PBX_NO_HANGUP_PEER
-#define FEATURE_RETURN_NO_HANGUP_PEER_PARKED    AST_PBX_NO_HANGUP_PEER_PARKED
 #define FEATURE_RETURN_PASSDIGITS               21
 #define FEATURE_RETURN_STOREDIGITS              22
 #define FEATURE_RETURN_SUCCESS                  23
@@ -584,21 +580,9 @@
 	if (!res)
 		res = ast_safe_sleep(chan, 1000);
 
-	if (!res) {
-		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_PARKED;
-				} 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 */
-		}
+	if (!res) { /* one direction used to call park_call.... */
+		masq_park_call_announce(parkee, parker, 0, NULL);
+		res = 0; /* PBX should hangup zombie channel */
 	}
 
 	ast_module_user_remove(u);
@@ -752,11 +736,11 @@
 		res = finishup(transferee);
 		if (res)
 			res = -1;
-		else if (!ast_park_call(transferee, transferer, 0, NULL)) {	/* success */
+		else if (!masq_park_call_announce(transferee, transferer, 0, NULL)) {	/* success */
 			/* We return non-zero, but tell the PBX not to hang the channel when
 			   the thread dies -- We have to be careful now though.  We are responsible for 
 			   hanging up the channel, else it will never be hung up! */
-			return (transferer == peer) ? AST_PBX_KEEPALIVE : AST_PBX_NO_HANGUP_PEER_PARKED;
+			return 0;
 		} else {
 			ast_log(LOG_WARNING, "Unable to park call %s\n", transferee->name);
 		}
@@ -1110,17 +1094,7 @@
 
 	ast_autoservice_stop(idle);
 
-	if (res == AST_PBX_KEEPALIVE) {
-		/* do not hangup peer if feature is to be activated on it */
-		if ((ast_test_flag(feature, AST_FEATURE_FLAG_ONPEER) && sense == FEATURE_SENSE_CHAN) || (ast_test_flag(feature, AST_FEATURE_FLAG_ONSELF) && sense == FEATURE_SENSE_PEER)) {
-			return FEATURE_RETURN_NO_HANGUP_PEER;
-		} else
-			return FEATURE_RETURN_PBX_KEEPALIVE;
-	} else if (res == AST_PBX_NO_HANGUP_PEER) {
-		return FEATURE_RETURN_NO_HANGUP_PEER;
-	} else if (res == AST_PBX_NO_HANGUP_PEER_PARKED) {
-		return FEATURE_RETURN_NO_HANGUP_PEER_PARKED;
-	} else if (res)
+	if (res)
 		return FEATURE_RETURN_SUCCESSBREAK;
 	
 	return FEATURE_RETURN_SUCCESS;	/*! \todo XXX should probably return res */
@@ -1713,13 +1687,13 @@
 
 	}
   before_you_go:
-	if (res != AST_PBX_KEEPALIVE && config->end_bridge_callback) {
+	if (config->end_bridge_callback) {
 		config->end_bridge_callback();
 	}
 
 	autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP);
 	ast_set_flag(chan, AST_FLAG_IN_AUTOLOOP);
-	if (res != AST_PBX_KEEPALIVE && !ast_test_flag(&(config->features_caller),AST_FEATURE_NO_H_EXTEN) && ast_exists_extension(chan, chan->context, "h", 1, chan->cid.cid_num)) {
+	if (!ast_test_flag(&(config->features_caller),AST_FEATURE_NO_H_EXTEN) && ast_exists_extension(chan, chan->context, "h", 1, chan->cid.cid_num)) {
 		struct ast_cdr *swapper;
 		char savelastapp[AST_MAX_EXTENSION];
 		char savelastdata[AST_MAX_EXTENSION];
@@ -1766,11 +1740,9 @@
 	ast_set2_flag(chan, autoloopflag, AST_FLAG_IN_AUTOLOOP);
 
 	/* obey the NoCDR() wishes. -- move the DISABLED flag to the bridge CDR if it was set on the channel during the bridge... */
-	if (res != AST_PBX_KEEPALIVE) {
-		new_chan_cdr = pick_unlocked_cdr(chan->cdr); /* the proper chan cdr, if there are forked cdrs */
-		if (new_chan_cdr && ast_test_flag(new_chan_cdr, AST_CDR_FLAG_POST_DISABLED))
-			ast_set_flag(bridge_cdr, AST_CDR_FLAG_POST_DISABLED);
-	}
+	new_chan_cdr = pick_unlocked_cdr(chan->cdr); /* the proper chan cdr, if there are forked cdrs */
+	if (new_chan_cdr && ast_test_flag(new_chan_cdr, AST_CDR_FLAG_POST_DISABLED))
+		ast_set_flag(bridge_cdr, AST_CDR_FLAG_POST_DISABLED);
 
 	/* we can post the bridge CDR at this point */
 	ast_cdr_end(bridge_cdr);
@@ -1798,23 +1770,9 @@
 	   5. After a bridge occurs, we have 2 or 3 channels' CDRs
 	      to attend to; if the chan or peer changed names,
 	      we have the before and after attached CDR's.
-	   6. Parking has to be accounted for in the code:
-	      a. Parking will cause ast_bridge_call to return
-	         either AST_PBX_NO_HANGUP_PEER or AST_PBX_NO_HANGUP_PEER_PARKED;
-			 in the latter case, peer is (most likely) a bad
-			 pointer, you can no longer deref it. If it does still
-			 exist, it is under another's thread control, and
-			 could be destroyed at any time.
-          b. The same applies to AST_PBX_KEEPALIVE, in which
-		     case, the chan ptr cannot be used, as another thread
-			 owns it and may have destroyed the channel.
-	      c. In the former case, you need to check peer to see if it 
-	         still exists before you deref it, and obtain a lock.
-	      d. In neither case should you do an ast_hangup(peer).
-		  e. Do not overwrite the result code from ast_bridge_call.
 	*/
 	
-	if (res != AST_PBX_KEEPALIVE && new_chan_cdr) {
+	if (new_chan_cdr) {
 		struct ast_channel *chan_ptr = NULL;
 		
 		if (strcasecmp(orig_channame, chan->name) != 0) { 
@@ -1840,7 +1798,7 @@
 		}
 	}
 
-	if (res != AST_PBX_NO_HANGUP_PEER_PARKED) { /* if the peer was involved in a park, don't even touch it; it's probably gone */
+	{
 		struct ast_channel *chan_ptr = NULL;
 		new_peer_cdr = pick_unlocked_cdr(peer->cdr); /* the proper chan cdr, if there are forked cdrs */
 		if (new_chan_cdr && ast_test_flag(new_chan_cdr, AST_CDR_FLAG_POST_DISABLED) && new_peer_cdr && !ast_test_flag(new_peer_cdr, AST_CDR_FLAG_POST_DISABLED))
@@ -2098,14 +2056,15 @@
 		res = ast_safe_sleep(chan, 1000);
 	/* Park the call */
 	if (!res) {
-		res = park_call_full(chan, chan, 0, NULL, orig_chan_name);
+		res = park_call_full(chan, chan, 0, NULL, orig_chan_name);  /* any advantage in using masq_park_call() instead? */
 		/* Continue on in the dialplan */
 		if (res == 1) {
 			ast_copy_string(chan->exten, orig_exten, sizeof(chan->exten));
 			chan->priority = orig_priority;
 			res = 0;
-		} else if (!res)
+		} else if (!res) {
 			res = AST_PBX_KEEPALIVE;
+		}
 	}
 
 	ast_module_user_remove(u);
@@ -2238,8 +2197,7 @@
 		ast_cdr_setdestchan(chan->cdr, peer->name);
 
 		/* Simulate the PBX hanging up */
-		if (res != AST_PBX_NO_HANGUP_PEER && res != AST_PBX_NO_HANGUP_PEER_PARKED)
-			ast_hangup(peer);
+		ast_hangup(peer);
 		ast_module_user_remove(u);
 		return res;
 	} else {




More information about the svn-commits mailing list