[asterisk-commits] russell: branch russell/issue_9520 r114454 - /team/russell/issue_9520/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 21 17:29:45 CDT 2008


Author: russell
Date: Mon Apr 21 17:29:45 2008
New Revision: 114454

URL: http://svn.digium.com/view/asterisk?view=rev&rev=114454
Log:
Fix a bunch of places where the peer ptr was magically getting set to NULL.  It
turns out that the ASTOBJ_UNREF() call automatically sets your pointer to NULL
for you.

Modified:
    team/russell/issue_9520/channels/chan_sip.c

Modified: team/russell/issue_9520/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/russell/issue_9520/channels/chan_sip.c?view=diff&rev=114454&r1=114453&r2=114454
==============================================================================
--- team/russell/issue_9520/channels/chan_sip.c (original)
+++ team/russell/issue_9520/channels/chan_sip.c Mon Apr 21 17:29:45 2008
@@ -2628,11 +2628,13 @@
 		ast_copy_flags(&peer->flags[1],&global_flags[1], SIP_PAGE2_RTAUTOCLEAR|SIP_PAGE2_RTCACHEFRIENDS);
 		if (ast_test_flag(&global_flags[1], SIP_PAGE2_RTAUTOCLEAR)) {
 			if (!AST_SCHED_DEL(sched, peer->expire)) {
-				ASTOBJ_UNREF(peer, sip_destroy_peer);
+				struct sip_peer *peer_ptr = peer;
+				ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 			}
 			peer->expire = ast_sched_add(sched, (global_rtautoclear) * 1000, expire_register, ASTOBJ_REF(peer));
 			if (peer->expire == -1) {
-				ASTOBJ_UNREF(peer, sip_destroy_peer);
+				struct sip_peer *peer_ptr = peer;
+				ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 			}
 		}
 		ASTOBJ_CONTAINER_LINK(&peerl,peer);
@@ -7986,20 +7988,24 @@
 	if (sipsock < 0) {
 		/* SIP isn't up yet, so schedule a poke only, pretty soon */
 		if (!AST_SCHED_DEL(sched, peer->pokeexpire)) {
-			ASTOBJ_UNREF(peer, sip_destroy_peer);
+			struct sip_peer *peer_ptr = peer;
+			ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 		}
 		peer->pokeexpire = ast_sched_add(sched, ast_random() % 5000 + 1, sip_poke_peer_s, ASTOBJ_REF(peer));
 		if (peer->pokeexpire == -1) {
-			ASTOBJ_UNREF(peer, sip_destroy_peer);
+			struct sip_peer *peer_ptr = peer;
+			ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 		}
 	} else
 		sip_poke_peer(peer);
 	if (!AST_SCHED_DEL(sched, peer->expire)) {
-		ASTOBJ_UNREF(peer, sip_destroy_peer);
+		struct sip_peer *peer_ptr = peer;
+		ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 	}
 	peer->expire = ast_sched_add(sched, (expiry + 10) * 1000, expire_register, ASTOBJ_REF(peer));
 	if (peer->expire == -1) {
-		ASTOBJ_UNREF(peer, sip_destroy_peer);
+		struct sip_peer *peer_ptr = peer;
+		ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 	}
 	register_peer_exten(peer, TRUE);
 }
@@ -8136,7 +8142,8 @@
 		/* This means remove all registrations and return OK */
 		memset(&peer->addr, 0, sizeof(peer->addr));
 		if (!AST_SCHED_DEL(sched, peer->expire)) {
-			ASTOBJ_UNREF(peer, sip_destroy_peer);
+			struct sip_peer *peer_ptr = peer;
+			ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 		}
 
 		destroy_association(peer);
@@ -8203,7 +8210,8 @@
 		ast_copy_string(peer->username, curi, sizeof(peer->username));
 
 	if (!AST_SCHED_DEL(sched, peer->expire)) {
-		ASTOBJ_UNREF(peer, sip_destroy_peer);
+		struct sip_peer *peer_ptr = peer;
+		ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 	}
 	if (expiry > max_expiry)
 		expiry = max_expiry;
@@ -8214,7 +8222,8 @@
 	} else {
 		peer->expire = ast_sched_add(sched, (expiry + 10) * 1000, expire_register, ASTOBJ_REF(peer));
 		if (peer->expire == -1) {
-			ASTOBJ_UNREF(peer, sip_destroy_peer);
+			struct sip_peer *peer_ptr = peer;
+			ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 		}
 	}
 	pvt->expiry = expiry;
@@ -12647,7 +12656,8 @@
 	}
 
 	if (!AST_SCHED_DEL(sched, peer->pokeexpire)) {
-		ASTOBJ_UNREF(peer, sip_destroy_peer);
+		struct sip_peer *peer_ptr = peer;
+		ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 	}
 
 	ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
@@ -15829,7 +15839,8 @@
 
 	/* This function gets called one place outside of the scheduler ... */
 	if (!AST_SCHED_DEL(sched, peer->pokeexpire)) {
-		ASTOBJ_UNREF(peer, sip_destroy_peer);
+		struct sip_peer *peer_ptr = peer;
+		ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 	}
 
 	/* There is no need to ASTOBJ_REF() here.  Just let the scheduled callback
@@ -15854,7 +15865,8 @@
 		/* IF we have no IP, or this isn't to be monitored, return
 		  imeediately after clearing things out */
 		if (!AST_SCHED_DEL(sched, peer->pokeexpire)) {
-			ASTOBJ_UNREF(peer, sip_destroy_peer);
+			struct sip_peer *peer_ptr = peer;
+			ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 		}
 		peer->lastms = 0;
 		peer->call = NULL;
@@ -15889,7 +15901,8 @@
 	build_callid_pvt(p);
 
 	if (!AST_SCHED_DEL(sched, peer->pokeexpire)) {
-		ASTOBJ_UNREF(peer, sip_destroy_peer);
+		struct sip_peer *peer_ptr = peer;
+		ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 	}
 
 	p->relatedpeer = peer;
@@ -15905,11 +15918,13 @@
 		sip_poke_noanswer(ASTOBJ_REF(peer));	/* Immediately unreachable, network problems */
 	} else {
 		if (!AST_SCHED_DEL(sched, peer->pokeexpire)) {
-			ASTOBJ_UNREF(peer, sip_destroy_peer);
+			struct sip_peer *peer_ptr = peer;
+			ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 		}
 		peer->pokeexpire = ast_sched_add(sched, peer->maxms * 2, sip_poke_noanswer, ASTOBJ_REF(peer));
 		if (peer->pokeexpire == -1) {
-			ASTOBJ_UNREF(peer, sip_destroy_peer);
+			struct sip_peer *peer_ptr = peer;
+			ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 		}
 	}
 
@@ -16713,7 +16728,8 @@
 			} else {
 				/* Non-dynamic.  Make sure we become that way if we're not */
 				if (!AST_SCHED_DEL(sched, peer->expire)) {
-					ASTOBJ_UNREF(peer, sip_destroy_peer);
+					struct sip_peer *peer_ptr = peer;
+					ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 				}
 				ast_clear_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC);
 				if (!obproxyfound || !strcasecmp(v->name, "outboundproxy")) {
@@ -17892,12 +17908,14 @@
 	ASTOBJ_CONTAINER_TRAVERSE(&peerl, 1, do {
 		ASTOBJ_WRLOCK(iterator);
 		if (!AST_SCHED_DEL(sched, iterator->pokeexpire)) {
-			ASTOBJ_UNREF(iterator, sip_destroy_peer);
+			struct sip_peer *peer_ptr = iterator;
+			ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 		}
 		ms += 100;
 		iterator->pokeexpire = ast_sched_add(sched, ms, sip_poke_peer_s, ASTOBJ_REF(iterator));
 		if (iterator->pokeexpire == -1) {
-			ASTOBJ_UNREF(iterator, sip_destroy_peer);
+			struct sip_peer *peer_ptr = iterator;
+			ASTOBJ_UNREF(peer_ptr, sip_destroy_peer);
 		}
 		ASTOBJ_UNLOCK(iterator);
 	} while (0)




More information about the asterisk-commits mailing list