]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 369437 via svnmerge from
authorAutomerge script <automerge@asterisk.org>
Wed, 27 Jun 2012 21:22:37 +0000 (21:22 +0000)
committerAutomerge script <automerge@asterisk.org>
Wed, 27 Jun 2012 21:22:37 +0000 (21:22 +0000)
file:///srv/subversion/repos/asterisk/branches/10

................
  r369437 | twilson | 2012-06-27 16:10:01 -0500 (Wed, 27 Jun 2012) | 16 lines

  Clean up after a reinvite that never gets a final response

  The basic problem is that if a re-INVITE is sent by Asterisk and it receives a
  provisional response, but no final response, then the dialog is never torn
  down. In addition to leaking memory, this also leaks file descriptors and will
  eventually lead to Asterisk no longer being able to process calls.

  This patch just keeps track of whether there is an outstanding re-INVITE, and if
  there is goes ahead and cleans up everything as though there was no outstanding
  reinvite.

  (closes issue ASTERISK-19992)
  ........

  Merged revisions 369436 from http://svn.asterisk.org/svn/asterisk/branches/1.8
................

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

channels/chan_sip.c
channels/sip/include/sip.h

index 9089dc33f3b7fc791c0fa43a45efd3ed70adb97e..a38d55a4a3709c2a739bc309e39b483923bc21c0 100644 (file)
@@ -6419,7 +6419,7 @@ static int sip_hangup(struct ast_channel *ast)
                                stop_session_timer(p);
                        }
 
-                       if (!p->pendinginvite) {
+                       if (!p->pendinginvite || p->ongoing_reinvite) {
                                struct ast_channel *bridge = ast_bridged_channel(oldowner);
                                char quality_buf[AST_MAX_USER_FIELD], *quality;
 
@@ -12347,7 +12347,7 @@ static int transmit_reinvite_with_sdp(struct sip_pvt *p, int t38version, int old
        initialize_initreq(p, &req);
        p->lastinvite = p->ocseq;
        ast_set_flag(&p->flags[0], SIP_OUTGOING);       /* Change direction of this dialog */
-
+       p->ongoing_reinvite = 1;
        return send_request(p, &req, XMIT_CRITICAL, p->ocseq);
 }
 
@@ -20836,8 +20836,12 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
                p->invitestate = INV_COMPLETED;
        
        /* Final response, clear out pending invite */
-       if ((resp == 200 || resp >= 300) && p->pendinginvite && seqno == p->pendinginvite)
+       if ((resp == 200 || resp >= 300) && p->pendinginvite && seqno == p->pendinginvite) {
                p->pendinginvite = 0;
+               if (reinvite) {
+                       p->ongoing_reinvite = 0;
+               }
+       }
 
        /* If this is a response to our initial INVITE, we need to set what we can use
         * for this peer.
index 15f2b91ff5239da5c9d1866961b598f7479e35ff..6a0f6cdb292f1404260233991f6e63255892c413 100644 (file)
@@ -1101,6 +1101,7 @@ struct sip_pvt {
        struct sip_auth_container *peerauth;/*!< Realm authentication credentials */
        int noncecount;                     /*!< Nonce-count */
        unsigned int stalenonce:1;          /*!< Marks the current nonce as responded too */
+       unsigned int ongoing_reinvite:1;    /*!< There is a reinvite in progress that might need to be cleaned up */
        char lastmsg[256];                  /*!< Last Message sent/received */
        int amaflags;                       /*!< AMA Flags */
        uint32_t pendinginvite; /*!< Any pending INVITE or state NOTIFY (in subscribe pvt's) ? (seqno of this) */