]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Only unlock our pvt and net locks if we are actually going to try to lock the owner...
authorJoshua Colp <jcolp@digium.com>
Thu, 5 Apr 2007 12:52:50 +0000 (12:52 +0000)
committerJoshua Colp <jcolp@digium.com>
Thu, 5 Apr 2007 12:52:50 +0000 (12:52 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@60213 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 9e11e0275041c1662dff2623a2fdaea9e9cbb28c..fae574002d65fa7d05d01d89a66198d41680b486 100644 (file)
@@ -11496,17 +11496,20 @@ retrylock:
                /* Go ahead and lock the owner if it has one -- we may need it */
                if (p->owner && ast_mutex_trylock(&p->owner->lock)) {
                        ast_log(LOG_DEBUG, "Failed to grab lock, trying again...\n");
-                       ast_mutex_unlock(&p->lock);
-                       ast_mutex_unlock(&netlock);
-                       /* Sleep for a very short amount of time */
-                       usleep(1);
-                       if (--lockretry)
+                       if (--lockretry) {
+                               ast_mutex_unlock(&p->lock);
+                               ast_mutex_unlock(&netlock);
+                               usleep(1);
                                goto retrylock;
+                       }
                }
                if (!lockretry) {
-                       ast_log(LOG_ERROR, "We could NOT get the channel lock for %s - Call ID %s! \n", p->owner->name, p->callid);
+                       if (p->owner)
+                               ast_log(LOG_ERROR, "We could NOT get the channel lock for %s - Call ID %s! \n", p->owner->name, p->callid);
                        ast_log(LOG_ERROR, "SIP MESSAGE JUST IGNORED: %s \n", req.data);
                        ast_log(LOG_ERROR, "BAD! BAD! BAD!\n");
+                       ast_mutex_unlock(&p->lock);
+                       ast_mutex_unlock(&netlock);
                        return 1;
                }
                memcpy(&p->recv, &sin, sizeof(p->recv));