From: BJ Weschke Date: Tue, 23 May 2006 17:31:05 +0000 (+0000) Subject: Sanity check code for an extended failure in trying to obtain a channel lock that... X-Git-Tag: 1.4.0-beta1~1237 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c4227714fd711aa0ee69387d645c6ce5578f2818;p=thirdparty%2Fasterisk.git 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. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@29735 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 583a6f2dc7..6a30bf4267 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -12098,6 +12098,7 @@ static int sipsock_read(int *id, int fd, short events, void *ignore) int nounlock; int recount = 0; char iabuf[INET_ADDRSTRLEN]; + int lockretrycount = 0; len = sizeof(sin); memset(&req, 0, sizeof(req)); @@ -12156,7 +12157,15 @@ retrylock: 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 */