[asterisk-commits] trunk r29735 - /trunk/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue May 23 10:31:06 MST 2006


Author: bweschke
Date: Tue May 23 12:31:05 2006
New Revision: 29735

URL: http://svn.digium.com/view/asterisk?rev=29735&view=rev
Log:
 Sanity check code for an extended failure in trying to obtain a channel lock that may have been obtained elsewhere. Prevents the monitor thread of the SIP module from going into an infinite loop, effectively, breaking SIP until you restart Asterisk or the mutex is unlocked, whichever comes first.


Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=29735&r1=29734&r2=29735&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue May 23 12:31:05 2006
@@ -12098,6 +12098,7 @@
 	int nounlock;
 	int recount = 0;
 	char iabuf[INET_ADDRSTRLEN];
+	int lockretrycount = 0;
 
 	len = sizeof(sin);
 	memset(&req, 0, sizeof(req));
@@ -12156,7 +12157,15 @@
 			ast_mutex_unlock(&netlock);
 			/* Sleep infintismly short amount of time */
 			usleep(1);
-			goto retrylock;
+			lockretrycount++;
+			if (lockretrycount < 100)
+				goto retrylock;
+		}
+		if (lockretrycount > 100) {
+			ast_log(LOG_ERROR, "We could NOT get the channel lock for %s! \n", p->owner->name);
+			ast_log(LOG_ERROR, "SIP MESSAGE JUST IGNORED: %s \n", req.data);
+			ast_log(LOG_ERROR, "BAD! BAD! BAD!\n");
+			return 1;
 		}
 		p->recv = sin;
 		if (recordhistory) /* This is a request or response, note what it was for */



More information about the asterisk-commits mailing list