[asterisk-commits] russell: branch 1.4 r115517 - /branches/1.4/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 7 13:17:20 CDT 2008


Author: russell
Date: Wed May  7 13:17:19 2008
New Revision: 115517

URL: http://svn.digium.com/view/asterisk?view=rev&rev=115517
Log:
Track peer references when stored in the sip_pvt struct as the peer related to
a qualify ping or a subscription.  This fixes some realtime related crashes.
(closes issue #12588)
(closes issue #12555)

Modified:
    branches/1.4/channels/chan_sip.c

Modified: branches/1.4/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_sip.c?view=diff&rev=115517&r1=115516&r2=115517
==============================================================================
--- branches/1.4/channels/chan_sip.c (original)
+++ branches/1.4/channels/chan_sip.c Wed May  7 13:17:19 2008
@@ -3109,8 +3109,10 @@
 	}
 
 	/* Remove link from peer to subscription of MWI */
-	if (p->relatedpeer && p->relatedpeer->mwipvt)
+	if (p->relatedpeer) {
 		p->relatedpeer->mwipvt = NULL;
+		ASTOBJ_UNREF(p->relatedpeer, sip_destroy_peer);
+	}
 
 	if (dumphistory)
 		sip_dump_history(p);
@@ -7921,8 +7923,11 @@
 	*/
 	if (ast_test_flag(&peer->flags[1], SIP_PAGE2_SELFDESTRUCT) ||
 	    ast_test_flag(&peer->flags[1], SIP_PAGE2_RTAUTOCLEAR)) {
-		peer = ASTOBJ_CONTAINER_UNLINK(&peerl, peer);
-		ASTOBJ_UNREF(peer, sip_destroy_peer);
+		struct sip_peer *peer_ptr = peer_ptr;
+		peer_ptr = ASTOBJ_CONTAINER_UNLINK(&peerl, peer);
+		if (peer_ptr) {
+			ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
+		}
 	}
 
 	ASTOBJ_UNREF(peer, sip_destroy_peer);
@@ -8693,7 +8698,6 @@
 		/* Peer fails ACL check */
 		if (peer) {
 			ASTOBJ_UNREF(peer, sip_destroy_peer);
-			peer = NULL;
 			res = AUTH_ACL_FAILED;
 		} else
 			res = AUTH_NOT_FOUND;
@@ -12679,6 +12683,7 @@
 	peer->pokeexpire = ast_sched_add(sched,
 		is_reachable ? DEFAULT_FREQ_OK : DEFAULT_FREQ_NOTOK,
 		sip_poke_peer_s, ASTOBJ_REF(peer));
+
 	if (peer->pokeexpire == -1) {
 		ASTOBJ_UNREF(peer, sip_destroy_peer);
 	}
@@ -15097,7 +15102,7 @@
 			/* We only allow one subscription per peer */
 			sip_destroy(authpeer->mwipvt);
 		authpeer->mwipvt = p;		/* Link from peer to pvt */
-		p->relatedpeer = authpeer;	/* Link from pvt to peer */
+		p->relatedpeer = ASTOBJ_REF(authpeer);	/* Link from pvt to peer */
 	} else { /* At this point, Asterisk does not understand the specified event */
 		transmit_response(p, "489 Bad Event", req);
 		if (option_debug > 1)
@@ -15922,7 +15927,7 @@
 		ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 	}
 
-	p->relatedpeer = peer;
+	p->relatedpeer = ASTOBJ_REF(peer);
 	ast_set_flag(&p->flags[0], SIP_OUTGOING);
 #ifdef VOCAL_DATA_HACK
 	ast_copy_string(p->username, "__VOCAL_DATA_SHOULD_READ_THE_SIP_SPEC__", sizeof(p->username));




More information about the asterisk-commits mailing list