aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorbweschke <bweschke@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-23 17:17:02 +0000
committerbweschke <bweschke@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-23 17:17:02 +0000
commit788bbeb7b3bbe1d961e71d1b016215d2b200f28c (patch)
tree441cf26f5cbd9b7704ea596df6c5fe398196b0c4 /channels
parent62a7522f316acf205715a3585b9e4ce260062823 (diff)
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: http://svn.digium.com/svn/asterisk/branches/1.2@29733 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 8719be134..72d95e2f5 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -11199,6 +11199,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));
@@ -11253,7 +11254,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;
}
memcpy(&p->recv, &sin, sizeof(p->recv));
if (recordhistory) {