[svn-commits] russell: branch russell/sip_refcount r140412 - /team/russell/sip_refcount/cha...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Aug 28 20:54:59 CDT 2008


Author: russell
Date: Thu Aug 28 20:54:58 2008
New Revision: 140412

URL: http://svn.digium.com/view/asterisk?view=rev&rev=140412
Log:
Mark the places that do not appear to be properly handling object reference
counts

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

Modified: team/russell/sip_refcount/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/russell/sip_refcount/channels/chan_sip.c?view=diff&rev=140412&r1=140411&r2=140412
==============================================================================
--- team/russell/sip_refcount/channels/chan_sip.c (original)
+++ team/russell/sip_refcount/channels/chan_sip.c Thu Aug 28 20:54:58 2008
@@ -3788,6 +3788,9 @@
 	 * Otherwise, there's a crashable race condition.
 	 *
 	 * NOTE: once peer is refcounted, this probably is no longer necessary.
+	 *
+	 * XXX This code does not take into account the peer reference count for these
+	 * scheduler entries!
 	 */
 	AST_SCHED_DEL(sched, peer->expire);
 	AST_SCHED_DEL(sched, peer->pokeexpire);
@@ -4019,6 +4022,7 @@
 		/* Cache peer */
 		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)) {
+			/* XXX take peer ref count into account for this scheduler entry */
 			AST_SCHED_REPLACE(peer->expire, sched, global_rtautoclear * 1000, expire_register, (void *) peer);
 			/* we could be incr. its refcount right here, but I guess, since
 			   peers hang around until module unload time anyway, it's not worth the trouble */
@@ -4516,6 +4520,8 @@
 		reg->call = dialog_unref(reg->call, "unref reg->call");
 		/* reg->call = sip_destroy(reg->call); */
 	}
+
+	/* XXX check sip_registry ref count for these scheduler entries */
 	AST_SCHED_DEL(sched, reg->expire);	
 	AST_SCHED_DEL(sched, reg->timeout);
 	
@@ -4602,6 +4608,7 @@
 
 	/* Destroy Session-Timers if allocated */
 	if (p->stimer) {
+		/* XXX check ref count for this scheduler entry */
 		if (p->stimer->st_active == TRUE && p->stimer->st_schedid > -1)
 			AST_SCHED_DEL(sched, p->stimer->st_schedid);
 		ast_free(p->stimer);
@@ -10154,11 +10161,13 @@
 	peer->addr.sin_addr = in;
 	peer->addr.sin_port = htons(port);
 	if (sipsock < 0) {
+		/* XXX check peer refcount for this scheduler entry */
 		/* SIP isn't up yet, so schedule a poke only, pretty soon */
 		AST_SCHED_REPLACE(peer->pokeexpire, sched, ast_random() % 5000 + 1, sip_poke_peer_s, peer);
 	} else {
 		sip_poke_peer(peer, 0);
 	}
+	/* XXX check peer refcount for this scheduler entry */
 	AST_SCHED_REPLACE(peer->expire, sched, (expire + 10) * 1000, expire_register, peer);
 	register_peer_exten(peer, TRUE);
 }
@@ -10292,6 +10301,7 @@
 	} else if (!strcasecmp(curi, "*") || !expire) {	/* Unregister this peer */
 		/* This means remove all registrations and return OK */
 		memset(&peer->addr, 0, sizeof(peer->addr));
+		/* XXX check peer refcount here */
 		AST_SCHED_DEL(sched, peer->expire);
 
 		destroy_association(peer);
@@ -10349,11 +10359,13 @@
 	if (!ast_strlen_zero(curi) && ast_strlen_zero(peer->username))
 		ast_copy_string(peer->username, curi, sizeof(peer->username));
 
+	/* XXX check peer refcount here */
 	AST_SCHED_DEL(sched, peer->expire);
 	if (expire > max_expiry)
 		expire = max_expiry;
 	if (expire < min_expiry)
 		expire = min_expiry;
+	/* XXX check peer refcount here */
 	peer->expire = peer->is_realtime && !ast_test_flag(&peer->flags[1], SIP_PAGE2_RTCACHEFRIENDS) ? -1 :
 		ast_sched_add(sched, (expire + 10) * 1000, expire_register, peer);
 	pvt->expiry = expire;
@@ -15604,6 +15616,7 @@
 		break;
 	case 403:	/* Forbidden */
 		ast_log(LOG_WARNING, "Forbidden - wrong password on authentication for REGISTER for '%s' to '%s'\n", p->registry->username, p->registry->hostname);
+		/* XXX check refcount here */
 		AST_SCHED_DEL(sched, r->timeout);
 		r->regstate = REG_STATE_NOAUTH;
 		p->needdestroy = 1;
@@ -15614,6 +15627,7 @@
 		if (r->call)
 			r->call = dialog_unref(r->call, "unsetting registry->call pointer-- case 404");
 		r->regstate = REG_STATE_REJECTED;
+		/* XXX check refcount here */
 		AST_SCHED_DEL(sched, r->timeout);
 		break;
 	case 407:	/* Proxy auth */
@@ -15629,6 +15643,7 @@
 	case 423:	/* Interval too brief */
 		r->expiry = atoi(get_header(req, "Min-Expires"));
 		ast_log(LOG_WARNING, "Got 423 Interval too brief for service %s@%s, minimum is %d seconds\n", p->registry->username, p->registry->hostname, r->expiry);
+		/* XXX check refcount here */
 		AST_SCHED_DEL(sched, r->timeout);
 		r->timeout = -1;
 		if (r->call) {
@@ -15651,6 +15666,7 @@
 		if (r->call)
 			r->call = dialog_unref(r->call, "unsetting registry->call pointer-- case 479");
 		r->regstate = REG_STATE_REJECTED;
+		/* XXX check refcount here */
 		AST_SCHED_DEL(sched, r->timeout);
 		break;
 	case 200:	/* 200 OK */
@@ -15668,6 +15684,7 @@
 		if (r->timeout > -1) {
 			ast_debug(1, "Cancelling timeout %d\n", r->timeout);
 		}
+		/* XXX check refcount here */
 		AST_SCHED_DEL(sched, r->timeout);
 		if (r->call)
 			r->call = dialog_unref(r->call, "unsetting registry->call pointer-- case 200");
@@ -15776,6 +15793,7 @@
 	p->needdestroy = 1;
 
 	/* Try again eventually */
+		/* XXX check refcount here */
 	AST_SCHED_REPLACE(peer->pokeexpire, sched,
 		is_reachable ? peer->qualifyfreq : DEFAULT_FREQ_NOTOK,
 		sip_poke_peer_s, peer);
@@ -19616,6 +19634,7 @@
 	}
 
 	if (p->stimer->st_active == TRUE) {
+		/* XXX check refcount here */
 		AST_SCHED_DEL(sched, p->stimer->st_schedid);
 		ast_debug(2, "Session timer stopped: %d - %s\n", p->stimer->st_schedid, p->callid);
 		start_session_timer(p);
@@ -19633,6 +19652,7 @@
 
 	if (p->stimer->st_active == TRUE) {
 		p->stimer->st_active = FALSE;
+		/* XXX check refcount here */
 		AST_SCHED_DEL(sched, p->stimer->st_schedid);
 		ast_debug(2, "Session timer stopped: %d - %s\n", p->stimer->st_schedid, p->callid);
 	}
@@ -19647,6 +19667,7 @@
 		return;
 	}
 
+		/* XXX check refcount here */
 	p->stimer->st_schedid  = ast_sched_add(sched, p->stimer->st_interval * 1000 / 2, proc_session_timer, p);
 	if (p->stimer->st_schedid < 0) {
 		ast_log(LOG_ERROR, "ast_sched_add failed.\n");
@@ -19921,6 +19942,7 @@
 	peer->lastms = -1;
 	ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "SIP/%s", peer->name);
 	/* Try again quickly */
+		/* XXX check refcount here */
 	AST_SCHED_REPLACE(peer->pokeexpire, sched, 
 		DEFAULT_FREQ_NOTOK, sip_poke_peer_s, peer);
 	return 0;
@@ -19939,6 +19961,7 @@
 	if ((!peer->maxms && !force) || !peer->addr.sin_addr.s_addr) {
 		/* IF we have no IP, or this isn't to be monitored, return
 		  immediately after clearing things out */
+		/* XXX check refcount here */
 		AST_SCHED_DEL(sched, peer->pokeexpire);
 		
 		peer->lastms = 0;
@@ -19982,6 +20005,7 @@
 	build_callid_pvt(p);
 	ao2_t_link(dialogs, p, "Linking in under new name");
 
+		/* XXX check refcount here */
 	AST_SCHED_DEL(sched, peer->pokeexpire);
 	
 	if (p->relatedpeer)
@@ -19998,6 +20022,7 @@
 	if (xmitres == XMIT_ERROR) {
 		sip_poke_noanswer(peer);	/* Immediately unreachable, network problems */
 	} else if (!force) {
+		/* XXX check refcount here */
 		AST_SCHED_REPLACE(peer->pokeexpire, sched, peer->maxms * 2, sip_poke_noanswer, peer);
 	}
 	dialog_unref(p, "unref dialog at end of sip_poke_peer, obtained from sip_alloc, just before it goes out of scope");
@@ -20855,6 +20880,7 @@
 				peer->host_dynamic = TRUE;
 			} else {
 				/* Non-dynamic.  Make sure we become that way if we're not */
+		/* XXX check refcount here */
 				AST_SCHED_DEL(sched, peer->expire);
 				peer->host_dynamic = FALSE;
 				srvlookup = v->value;
@@ -22395,6 +22421,7 @@
 	while ((peer = ao2_t_iterator_next(&i, "iterate thru peers table"))) {
 		ao2_lock(peer);
 		ms += 100;
+		/* XXX check refcount here */
 		AST_SCHED_REPLACE(peer->pokeexpire, sched, ms, sip_poke_peer_s, peer);
 		ao2_unlock(peer);
 		unref_peer(peer, "toss iterator peer ptr");




More information about the svn-commits mailing list