[svn-commits] rizzo: branch rizzo/astobj2 r47839 - /team/rizzo/astobj2/channels/chan_sip.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Sun Nov 19 03:02:53 MST 2006


Author: rizzo
Date: Sun Nov 19 04:02:52 2006
New Revision: 47839

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47839
Log:
use sip_destroy() and not __sip_destroy() when shutting down the module.
Apart from lock/unlock the list on each operation (but unloading the
module is such a rare operation that we do not care)
we lose no efficiency because we always delete the first item
(so, the loop is still O(N) and not O(N^2)), and
gain in readability because reduce the number of places where the "non standard"
destructor __sip_destroy() is invoked.

I suggest this for trunk as well.


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=47839&r1=47838&r2=47839
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Sun Nov 19 04:02:52 2006
@@ -17595,7 +17595,7 @@
 /*! \brief PBX unload module API */
 static int unload_module(void)
 {
-	struct sip_pvt *p, *pl;
+	struct sip_pvt *p;
 	
 	/* First, take us out of the channel type list */
 	ast_channel_unregister(&sip_tech);
@@ -17625,6 +17625,7 @@
 
 #ifdef USE_AO2
 	{
+		/* should do this with a callback */
 		ao2_iterator i = ao2_iterator_init(dialogs, 0);
 		while ((p = ao2_iterator_next(&i))) {
 			if (p->owner)
@@ -17652,20 +17653,12 @@
 	ast_mutex_unlock(&monlock);
 
 #ifdef USE_AO2
-	pl = NULL;	/* XXX silence compiler */
 	ao2_ref(dialogs, -1);
 	dialogs = NULL;
 #else
-	dialoglist_lock();
 	/* Destroy all the dialogs and free their memory */
-	p = dialoglist;
-	while (p) {
-		pl = p;
-		p = p->next;
-		__sip_destroy(pl);
-	}
-	dialoglist = NULL;
-	dialoglist_unlock();
+	while (dialoglist)
+		sip_destroy(dialoglist);
 #endif
 	/* Free memory for local network address mask */
 	ast_free_ha(localaddr);



More information about the svn-commits mailing list