Issues related to issue #7828 - segfault with MWI subscriptions and realtime.
authorOlle Johansson <oej@edvina.net>
Sun, 29 Oct 2006 17:07:47 +0000 (17:07 +0000)
committerOlle Johansson <oej@edvina.net>
Sun, 29 Oct 2006 17:07:47 +0000 (17:07 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46400 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index fe257a0..bd1f0f0 100644 (file)
@@ -1981,6 +1981,10 @@ static int __sip_autodestruct(void *data)
                return 10000;   /* Reschedule this destruction so that we know that it's gone */
        }
 
+       if (p->subscribed == MWI_NOTIFICATION)
+               if (p->relatedpeer)
+                       ASTOBJ_UNREF(p->relatedpeer,sip_destroy_peer);  /* Remove link to peer. If it's realtime, make sure it's gone from memory) */
+
        /* Reset schedule ID */
        p->autokillid = -1;
 
@@ -1990,11 +1994,10 @@ static int __sip_autodestruct(void *data)
        if (p->owner) {
                ast_log(LOG_WARNING, "Autodestruct on dialog '%s' with owner in place (Method: %s)\n", p->callid, sip_methods[p->method].text);
                ast_queue_hangup(p->owner);
-       } else if (p->refer) {
+       } else if (p->refer)
                transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, 1);
-       } else {
+       else 
                sip_destroy(p);
-       }
        return 0;
 }
 
@@ -2916,7 +2919,7 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner)
                ast_verbose("Really destroying SIP dialog '%s' Method: %s\n", p->callid, sip_methods[p->method].text);
 
        /* Remove link from peer to subscription of MWI */
-       if (p->relatedpeer && p->relatedpeer->mwipvt)
+       if (p->relatedpeer && p->relatedpeer->mwipvt) 
                p->relatedpeer->mwipvt = NULL;
 
        if (dumphistory)