[asterisk-commits] file: trunk r148867 - /trunk/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Oct 14 10:00:41 CDT 2008


Author: file
Date: Tue Oct 14 10:00:41 2008
New Revision: 148867

URL: http://svn.digium.com/view/asterisk?view=rev&rev=148867
Log:
Fix reference count issue that Russell brought up in SIP MWI NOTIFY support. Bump the reference count up before we add it to the scheduler, duh.

Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=148867&r1=148866&r2=148867
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Oct 14 10:00:41 2008
@@ -9376,7 +9376,7 @@
 /*! \brief Send a subscription or resubscription for MWI */
 static int sip_subscribe_mwi_do(const void *data)
 {
-	struct sip_subscription_mwi *mwi = ASTOBJ_REF((struct sip_subscription_mwi *) data);
+	struct sip_subscription_mwi *mwi = (struct sip_subscription_mwi*)data;
 	
 	if (!mwi) {
 		return -1;
@@ -15905,7 +15905,9 @@
 			p->options = NULL;
 		}
 		p->mwi->subscribed = 1;
-		p->mwi->resub = ast_sched_add(sched, mwi_expiry * 1000, sip_subscribe_mwi_do, p->mwi);
+		if ((p->mwi->resub = ast_sched_add(sched, mwi_expiry * 1000, sip_subscribe_mwi_do, ASTOBJ_REF(p->mwi))) < 0) {
+			ASTOBJ_UNREF(p->mwi, sip_subscribe_mwi_destroy);
+		}
 		break;
 	case 401:
 	case 407:
@@ -23063,7 +23065,9 @@
 	ASTOBJ_CONTAINER_TRAVERSE(&submwil, 1, do {
 		ASTOBJ_WRLOCK(iterator);
 		AST_SCHED_DEL(sched, iterator->resub);
-		iterator->resub = ast_sched_add(sched, 1, sip_subscribe_mwi_do, iterator);
+		if ((iterator->resub = ast_sched_add(sched, 1, sip_subscribe_mwi_do, ASTOBJ_REF(iterator))) < 0) {
+			ASTOBJ_UNREF(iterator, sip_subscribe_mwi_destroy);
+		}
 		ASTOBJ_UNLOCK(iterator);
 	} while (0));
 }




More information about the asterisk-commits mailing list