[svn-commits] murf: branch murf/bug11210 r93627 - /team/murf/bug11210/channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Dec 18 11:28:53 CST 2007


Author: murf
Date: Tue Dec 18 11:28:53 2007
New Revision: 93627

URL: http://svn.digium.com/view/asterisk?view=rev&rev=93627
Log:
Found one place where autokillid was being illegally set to -1, without sched_del'ing it. Not a good practice, and was leaving dialogs laying around in its wake, to leak memory.

Modified:
    team/murf/bug11210/channels/chan_sip.c

Modified: team/murf/bug11210/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_sip.c?view=diff&rev=93627&r1=93626&r2=93627
==============================================================================
--- team/murf/bug11210/channels/chan_sip.c (original)
+++ team/murf/bug11210/channels/chan_sip.c Tue Dec 18 11:28:53 2007
@@ -2114,9 +2114,9 @@
 	
 	if (dialog->autokillid > -1) {
 		ast_log(LOG_WARNING,"About to sched_del autokill for dialog %s in dialog_unlink_all\n", dialog->callid);
+		dialog->autokillid = -1;
 		if (ast_sched_del(sched, dialog->autokillid)==0)
 			dialog_unref(dialog,"when you delete the autokillid sched, you should dec the refcount for the stored dialog ptr");
-		dialog->autokillid = -1;
 	}
 	return NULL;
 }
@@ -2676,7 +2676,16 @@
 			p->relatedpeer = unref_peer(p->relatedpeer,"__sip_autodestruct: unref peer p->relatedpeer");	/* Remove link to peer. If it's realtime, make sure it's gone from memory) */
 
 	/* Reset schedule ID */
-	p->autokillid = -1;  /* HUH? Won't this cause problems? the event is still scheduled? */
+	if (p->autokillid != -1) {
+		int res3;
+		ast_log(LOG_WARNING,"About to sched_del autokillid(%d) for dialog %s in sip_cancel_destroy\n", p->autokillid, p->callid);
+		res3 = ast_sched_del(sched, p->autokillid);
+		append_history(p, "CancelDestroy", "");
+		p->autokillid = -1;
+		if (res3 == 0)
+			dialog_unref(p,"dialog unrefd because autokillid sched is being deleted");
+	}
+	
 
 	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);
@@ -2716,7 +2725,7 @@
 	if (p->do_history)
 		append_history(p, "SchedDestroy", "%d ms", ms);
 	ast_log(LOG_WARNING,"About to sched_add sip_autodestruct for dialog %s in sip_scheddestroy\n", p->callid);
-	p->autokillid = ast_sched_add(sched, ms, __sip_autodestruct, dialog_ref(p,"sip_scheddestroy: setting ref as passing into ast_sched_add"));
+	p->autokillid = ast_sched_add(sched, ms, __sip_autodestruct, dialog_ref(p,"setting ref as passing into ast_sched_add for __sip_autodestruct"));
 }
 
 /*! \brief Cancel destruction of SIP dialog.
@@ -2732,7 +2741,7 @@
 		append_history(p, "CancelDestroy", "");
 		p->autokillid = -1;
 		if (res3 == 0)
-			dialog_unref(p,"dialog unrefd because autokillid is > -1");
+			dialog_unref(p,"dialog unrefd because autokillid is de-sched'd");
 	}
 }
 
@@ -3828,7 +3837,7 @@
 		}
 	}
 	sip_pvt_unlock(p);
-	dialog_unref(p,"unreffing arg passed into auto_congest callback");
+	dialog_unref(p,"unreffing arg passed into auto_congest callback (p->initid)");
 	return 0;
 }
 
@@ -3917,7 +3926,7 @@
 		/* Initialize auto-congest time */
 		ast_log(LOG_WARNING,"About to sched_replace autocongest for dialog %s in sip_call\n", p->callid);
 		p->initid = ast_sched_replace(p->initid, sched, p->timer_b, 
-									  auto_congest, dialog_ref(p,"this is a pointer for the autocongest callback to use"));
+									  auto_congest, dialog_ref(p,"sched:replace:this is a pointer for the autocongest callback to use (p->initid)"));
 	}
 
 	return res;
@@ -4010,9 +4019,9 @@
 	}
 	if (p->autokillid > -1) {
 		ast_log(LOG_WARNING,"About to sched_del autokillid(%d) for dialog %s in __sip_destroy\n", p->autokillid, p->callid);
+		p->autokillid = -1;
 		if (ast_sched_del(sched, p->autokillid)==0)
 			dialog_unref(p,"when you delete the autokillid sched, you should dec the refcount for the stored dialog ptr");
-		p->autokillid = -1;
 	}
 	
 	if (p->rtp)
@@ -14197,7 +14206,7 @@
 				/* Reset the flag after a while 
 				 */
 				int wait = 3 + ast_random() % 5;
-				p->waitid = ast_sched_add(sched, wait, sip_reinvite_retry, dialog_ref(p,"passing dialog ptr into sched structure based on waitid.")); 
+				p->waitid = ast_sched_add(sched, wait, sip_reinvite_retry, dialog_ref(p,"passing dialog ptr into sched structure based on waitid for sip_reinvite_retry.")); 
 				ast_log(LOG_WARNING,"just did sched_add waitid(%d) for sip_reinvite_retry for dialog %s in handle_response_invite\n", p->waitid, p->callid);
 				ast_debug(2, "Reinvite race. Waiting %d secs before retry\n", wait);
 			}




More information about the svn-commits mailing list