]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_sip: fix a deadlock in check_rtp_timeout.
authorRussell Bryant <russell@russellbryant.com>
Fri, 6 May 2011 19:46:49 +0000 (19:46 +0000)
committerRussell Bryant <russell@russellbryant.com>
Fri, 6 May 2011 19:46:49 +0000 (19:46 +0000)
Don't block doing silly deadlock avoidance.  Just return and try again later.
The funciton gets called often enough that it's fine.  Also, this change was
already made in trunk.

(closes issue #18791)
Reported by: irroot
Patches:
      chan_sip.rtptimeout.patch uploaded by irroot (license 52)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@317865 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 576df5dc26c072c637b7a407514a5eedb4251367..ca5dc72c97e2f67346f1868ab983e6599d1897ef 100644 (file)
@@ -24603,13 +24603,12 @@ static void check_rtp_timeout(struct sip_pvt *dialog, time_t t)
                if (!ast_test_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD) || (ast_rtp_instance_get_hold_timeout(dialog->rtp) && (t > dialog->lastrtprx + ast_rtp_instance_get_hold_timeout(dialog->rtp)))) {
                        /* Needs a hangup */
                        if (ast_rtp_instance_get_timeout(dialog->rtp)) {
-                               while (dialog->owner && ast_channel_trylock(dialog->owner)) {
-                                       sip_pvt_unlock(dialog);
-                                       usleep(1);
-                                       sip_pvt_lock(dialog);
-                               }
-                               if (!dialog->owner) {
-                                       return; /* channel hangup can occur during deadlock avoidance. */
+                               if (!dialog->owner || ast_channel_trylock(dialog->owner)) {
+                                       /*
+                                        * Don't block, just try again later.
+                                        * If there was no owner, the call is dead already.
+                                        */
+                                       return;
                                }
                                ast_log(LOG_NOTICE, "Disconnecting call '%s' for lack of RTP activity in %ld seconds\n",
                                        dialog->owner->name, (long) (t - dialog->lastrtprx));