]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Avoid a deadlock in add_header_max_forwards().
authorMatthew Nicholson <mnicholson@digium.com>
Wed, 11 Aug 2010 17:27:59 +0000 (17:27 +0000)
committerMatthew Nicholson <mnicholson@digium.com>
Wed, 11 Aug 2010 17:27:59 +0000 (17:27 +0000)
Related to r276951

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

channels/chan_sip.c

index d6e4ccc1d8ff06cb7e9cb3d2e9d4d8f189c42fb5..3463843f3fe67630e90123c5416489fffc5e9556 100644 (file)
@@ -9035,8 +9035,16 @@ static int add_header_max_forwards(struct sip_pvt *dialog, struct sip_request *r
        char clen[10];
        const char *max = NULL;
 
+       /* deadlock avoidance */
+       while (dialog->owner && ast_channel_trylock(dialog->owner)) {
+               sip_pvt_unlock(dialog);
+               usleep(1);
+               sip_pvt_lock(dialog);
+       }
+
        if (dialog->owner) {
                max = pbx_builtin_getvar_helper(dialog->owner, "SIP_MAX_FORWARDS");
+               ast_channel_unlock(dialog->owner);
        }
 
        /* The channel variable overrides the peer/channel value */