[asterisk-commits] rizzo: branch rizzo/astobj2 r47272 - /team/rizzo/astobj2/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Nov 7 11:03:55 MST 2006


Author: rizzo
Date: Tue Nov  7 12:03:54 2006
New Revision: 47272

URL: http://svn.digium.com/view/asterisk?rev=47272&view=rev
Log:
move towards 'normal form' for the dialog expiration loop in do_monitor():

- fastrestart doesn't need to be checked at each iteration;
- the current time is not used outside;

What remains to do is modify __sip_destroy so unlinking occurs
outside the function, and we don't have to rescan the list
at every match.


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?rev=47272&r1=47271&r2=47272&view=diff
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Tue Nov  7 12:03:54 2006
@@ -14987,7 +14987,6 @@
 	int res;
 	struct sip_pvt *sip;
 	struct sip_peer *peer = NULL;
-	time_t t;
 	int fastrestart = FALSE;
 	int lastpeernum = -1;
 	int curpeernum;
@@ -15006,27 +15005,30 @@
 			sip_do_reload(sip_reloadreason);
 		}
 		/* Check for dialogs needing to be killed */
-		dialoglist_lock();
-restartsearch:		
-		t = time(NULL);
 		/* don't scan the dialogs list if it hasn't been a reasonable period
 		   of time since the last time we did it (when MWI is being sent, we can
 		   get back to this point every millisecond or less)
 		*/
-		for (sip = dialoglist; !fastrestart && sip; sip = sip->next) {
-			sip_pvt_lock(sip);
-			/* Check RTP timeouts and kill calls if we have a timeout set and do not get RTP */
-			check_rtp_timeout(sip, t);
-			/* If we have sessions that needs to be destroyed, do it now */
-			if (ast_test_flag(&sip->flags[0], SIP_NEEDDESTROY) && !sip->packets &&
-			    !sip->owner) {
+		if (!fastrestart) {
+			time_t t;
+			dialoglist_lock();
+restartsearch:		
+			t = time(NULL);
+			for (sip = dialoglist; sip; sip = sip->next) {
+				sip_pvt_lock(sip);
+				/* Check RTP timeouts and kill calls if we have a timeout set and do not get RTP */
+				check_rtp_timeout(sip, t);
+				/* If we have sessions that needs to be destroyed, do it now */
+				if (ast_test_flag(&sip->flags[0], SIP_NEEDDESTROY) && !sip->packets &&
+				    !sip->owner) {
+					sip_pvt_unlock(sip);
+					__sip_destroy(sip, TRUE, FALSE);
+					goto restartsearch;
+				}
 				sip_pvt_unlock(sip);
-				__sip_destroy(sip, TRUE, FALSE);
-				goto restartsearch;
 			}
-			sip_pvt_unlock(sip);
-		}
-		dialoglist_unlock();
+			dialoglist_unlock();
+		}
 
 		pthread_testcancel();
 		/* Wait for sched or io */
@@ -15047,7 +15049,6 @@
 		}
 
 		/* Send MWI notifications to peers - static and cached realtime peers */
-		t = time(NULL);
 		fastrestart = FALSE;
 		curpeernum = 0;
 		peer = NULL;



More information about the asterisk-commits mailing list