[asterisk-commits] mmichelson: branch 1.6.1 r157498 - in /branches/1.6.1: ./ channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Nov 18 16:01:19 CST 2008


Author: mmichelson
Date: Tue Nov 18 16:01:18 2008
New Revision: 157498

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

........
r157496 | mmichelson | 2008-11-18 15:59:24 -0600 (Tue, 18 Nov 2008) | 6 lines

Based on Russell's advice on the asterisk-dev list, I have
changed from using a global lock in update_call_counter to
using the locks within the sip_pvt and sip_peer structures
instead.


........

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/channels/chan_sip.c

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

Modified: branches/1.6.1/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/channels/chan_sip.c?view=diff&rev=157498&r1=157497&r2=157498
==============================================================================
--- branches/1.6.1/channels/chan_sip.c (original)
+++ branches/1.6.1/channels/chan_sip.c Tue Nov 18 16:01:18 2008
@@ -1823,9 +1823,6 @@
 	SDP_T38_ACCEPT,   /*!< Remote side accepted our T38 request */
 };
 
-/*! \brief Protect the callcounters inuse,inringing and the corresponding flags */
-AST_MUTEX_DEFINE_STATIC(callctrlock);
-
 /*---------------------------- Forward declarations of functions in chan_sip.c */
 /* Note: This is added to help splitting up chan_sip.c into several files
 	in coming releases. */
@@ -4727,36 +4724,43 @@
 	case DEC_CALL_LIMIT:
 		/* Decrement inuse count if applicable */
 		if (inuse) {
-			ast_mutex_lock(&callctrlock);
+			sip_pvt_lock(fup);
+			ao2_lock(p);
 			if ((*inuse > 0) && ast_test_flag(&fup->flags[0], SIP_INC_COUNT)) {
 				(*inuse)--;
 				ast_clear_flag(&fup->flags[0], SIP_INC_COUNT);
 			} else {
 				*inuse = 0;
 			}
-			ast_mutex_unlock(&callctrlock);
+			ao2_unlock(p);
+			sip_pvt_unlock(fup);
 		}
 
 		/* Decrement ringing count if applicable */
 		if (inringing) {
-			ast_mutex_lock(&callctrlock);
+			sip_pvt_lock(fup);
+			ao2_lock(p);
 			if ((*inringing > 0)&& ast_test_flag(&fup->flags[0], SIP_INC_RINGING)) {
 				(*inringing)--;
 				ast_clear_flag(&fup->flags[0], SIP_INC_RINGING);
 			} else {
 			   *inringing = 0;
 			}
-			ast_mutex_unlock(&callctrlock);
+			ao2_unlock(p);
+			sip_pvt_unlock(fup);
 		}
 
 		/* Decrement onhold count if applicable */
-		ast_mutex_lock(&callctrlock);
+		sip_pvt_lock(fup);
+		ao2_lock(p);
 		if (ast_test_flag(&fup->flags[1], SIP_PAGE2_CALL_ONHOLD) && global_notifyhold) {
 			ast_clear_flag(&fup->flags[1], SIP_PAGE2_CALL_ONHOLD);
-			ast_mutex_unlock(&callctrlock);
+			ao2_unlock(p);
+			sip_pvt_unlock(fup);
 			sip_peer_hold(fup, FALSE);
 		} else {
-			ast_mutex_unlock(&callctrlock);
+			ao2_unlock(p);
+			sip_pvt_unlock(fup);
 		}
 		if (sipdebug)
 			ast_debug(2, "Call %s %s '%s' removed from call limit %d\n", outgoing ? "to" : "from", "peer", name, *call_limit);
@@ -4773,20 +4777,24 @@
 			}
 		}
 		if (inringing && (event == INC_CALL_RINGING)) {
-			ast_mutex_lock(&callctrlock);
+			sip_pvt_lock(fup);
+			ao2_lock(p);
 			if (!ast_test_flag(&fup->flags[0], SIP_INC_RINGING)) {
 				(*inringing)++;
 				ast_set_flag(&fup->flags[0], SIP_INC_RINGING);
 			}
-			ast_mutex_unlock(&callctrlock);
+			ao2_unlock(p);
+			sip_pvt_unlock(fup);
 		}
 		if (inuse) {
-			ast_mutex_lock(&callctrlock);
+			sip_pvt_lock(fup);
+			ao2_lock(p);
 			if (!ast_test_flag(&fup->flags[0], SIP_INC_COUNT)) {
 				(*inuse)++;
 				ast_set_flag(&fup->flags[0], SIP_INC_COUNT);
 			}
-			ast_mutex_unlock(&callctrlock);
+			ao2_unlock(p);
+			sip_pvt_unlock(fup);
 		}
 		if (sipdebug) {
 			ast_debug(2, "Call %s %s '%s' is %d out of %d\n", outgoing ? "to" : "from", "peer", name, *inuse, *call_limit);
@@ -4795,12 +4803,14 @@
 
 	case DEC_CALL_RINGING:
 		if (inringing) {
-			ast_mutex_lock(&callctrlock);
+			sip_pvt_lock(fup);
+			ao2_lock(p);
 			if (ast_test_flag(&fup->flags[0], SIP_INC_RINGING)) {
 				(*inringing)--;
 				ast_clear_flag(&fup->flags[0], SIP_INC_RINGING);
 			}
-			ast_mutex_unlock(&callctrlock);
+			ao2_unlock(p);
+			sip_pvt_unlock(fup);
 		}
 		break;
 




More information about the asterisk-commits mailing list