]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 283381 via svnmerge from
authorDavid Vossel <dvossel@digium.com>
Tue, 24 Aug 2010 16:11:18 +0000 (16:11 +0000)
committerDavid Vossel <dvossel@digium.com>
Tue, 24 Aug 2010 16:11:18 +0000 (16:11 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.6.2

................
  r283381 | dvossel | 2010-08-24 11:07:37 -0500 (Tue, 24 Aug 2010) | 18 lines

  Merged revisions 283380 via svnmerge from
  https://origsvn.digium.com/svn/asterisk/branches/1.4

  ........
    r283380 | dvossel | 2010-08-24 11:01:51 -0500 (Tue, 24 Aug 2010) | 11 lines

    This fix makes sure the ast_channel hangs up correctly when the dialog's PENDING_BYE flag is set.

    When the pending bye flag is used, it is possible that the dialog will terminate
    and leave the sip_pvt->owner channel up.  This is because we never hangup the
    ast_channel after sending the SIP_BYE request.  When we receive the response for
    the SIP_BYE we set need_destroy which we would expect to destroy the dialog on the
    next do_monitor loop, but this is not the case.  The dialog will only be destroyed
    once the owner is hungup even with the need_destroy flag set.  This patch sets the
    softhangup flag on the ast_channel when a SIP_BYE request is sent as a result of the
    pending bye flag.
  ........
................

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

channels/chan_sip.c

index 40e679209a8171e3b8b0107eb4c7cecb14f77118..8d66a62ac7b39eb70cf01e5a02356595811ef462 100644 (file)
@@ -18468,7 +18468,11 @@ static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req, char
        }
 }
 
-/*! \brief Check pending actions on SIP call */
+/*! \brief Check pending actions on SIP call 
+ *
+ * \note both sip_pvt and sip_pvt's owner channel (if present)
+ *  must be locked for this function.
+ */
 static void check_pendings(struct sip_pvt *p)
 {
        if (ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
@@ -18483,6 +18487,9 @@ static void check_pendings(struct sip_pvt *p)
                        if (p->pendinginvite)
                                return;
 
+                       if (p->owner) {
+                               ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_DEV);
+                       }
                        /* Perhaps there is an SD change INVITE outstanding */
                        transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, TRUE);
                }
@@ -18508,12 +18515,21 @@ static void check_pendings(struct sip_pvt *p)
 static int sip_reinvite_retry(const void *data)
 {
        struct sip_pvt *p = (struct sip_pvt *) data;
+       struct ast_channel *owner;
 
        sip_pvt_lock(p); /* called from schedule thread which requires a lock */
+       while ((owner = p->owner) && ast_channel_trylock(owner)) {
+               sip_pvt_unlock(p);
+               usleep(1);
+               sip_pvt_lock(p);
+       }
        ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
        p->waitid = -1;
        check_pendings(p);
        sip_pvt_unlock(p);
+       if (owner) {
+               ast_channel_unlock(owner);
+       }
        dialog_unref(p, "unref the dialog ptr from sip_reinvite_retry, because it held a dialog ptr");
        return 0;
 }