]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 281760 via svnmerge from
authorMatthew Nicholson <mnicholson@digium.com>
Wed, 11 Aug 2010 17:29:16 +0000 (17:29 +0000)
committerMatthew Nicholson <mnicholson@digium.com>
Wed, 11 Aug 2010 17:29:16 +0000 (17:29 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r281760 | mnicholson | 2010-08-11 12:27:59 -0500 (Wed, 11 Aug 2010) | 4 lines

  Avoid a deadlock in add_header_max_forwards().

  Related to r276951
........

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

channels/chan_sip.c

index d4e9f0af8e7595ca3bd31223f56a37b7d2beda8b..2a656bad8177f0c8ac320718ab69d53beb961128 100644 (file)
@@ -9038,8 +9038,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 */