[asterisk-commits] murf: branch murf/bug11210 r98271 - in /team/murf/bug11210: channels/ include...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 11 12:48:56 CST 2008


Author: murf
Date: Fri Jan 11 12:48:55 2008
New Revision: 98271

URL: http://svn.digium.com/view/asterisk?view=rev&rev=98271
Log:
Some more debug in the registry destruction loop to see what's going on.

Modified:
    team/murf/bug11210/channels/chan_sip.c
    team/murf/bug11210/include/asterisk/astobj2.h

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=98271&r1=98270&r2=98271
==============================================================================
--- team/murf/bug11210/channels/chan_sip.c (original)
+++ team/murf/bug11210/channels/chan_sip.c Fri Jan 11 12:48:55 2008
@@ -17827,9 +17827,11 @@
 	}
 	if (monitor_thread != AST_PTHREADT_NULL) {
 		/* Wake up the thread */
+		ast_log(LOG_NOTICE,"about to sigurg the SIP monitor thread.");
 		pthread_kill(monitor_thread, SIGURG);
 	} else {
 		/* Start a new monitor */
+		ast_log(LOG_NOTICE,"about to fire up a thread for the SIP do_monitor().");
 		if (ast_pthread_create_background(&monitor_thread, NULL, do_monitor, NULL) < 0) {
 			ast_mutex_unlock(&monlock);
 			ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
@@ -19206,17 +19208,33 @@
 
 		/* First, destroy all outstanding registry calls */
 		/* This is needed, since otherwise active registry entries will not be destroyed */
-		ASTOBJ_CONTAINER_TRAVERSE(&regl, 1, do {
-			ASTOBJ_RDLOCK(iterator); /* was RDLOCK */
-			if (iterator->call) {
-				ast_debug(3, "Destroying active SIP dialog for registry %s@%s\n", iterator->username, iterator->hostname);
-				/* This will also remove references to the registry */
-				dialog_unlink_all(iterator->call, TRUE, TRUE);
-				iterator->call = dialog_unref(iterator->call,"remove iterator->call from registry traversal");
-				/* iterator->call = sip_destroy(iterator->call); */
-			}
-			ASTOBJ_UNLOCK(iterator);
-
+		ASTOBJ_CONTAINER_TRAVERSE(&regl, 1, do {  /* regl is locked */
+				ast_log(LOG_NOTICE,"#1c.1. About to get iterator lock for registry entry ");
+				
+				/* avoid a deadlock in the unlink_all call, if iterator->call's (a dialog) registry entry
+				   is this registry entry. In other words, if the dialog we are pointing to points back to 
+				   us, then if we get a lock on this object, and try to UNREF it, we will deadlock, because
+				   we already ... NO. This is not the problem. */
+#ifdef INANE_ATTEMPT_AT_HUMOR
+				if (iterator->call && iterator->call->registry && iterator->call->registry->call == iterator->call)
+					iterator->call->registry->call = dialog_unref(iterator->call, "null out the registry's call dialog field before unlink_all");
+				if (iterator->call && iterator->call->registry)
+					iterator->call->registry = registry_unref(iterator->call->registry, "delete dialog's registry entry before unlink_all");
+				ast_log(LOG_NOTICE,"#1c.2. Right now....");
+#endif
+				ASTOBJ_RDLOCK(iterator); /* was RDLOCK  and now regl is locked, and the object is also locked */
+				if (iterator->call) {
+					ast_debug(3, "Destroying active SIP dialog for registry %s@%s\n", iterator->username, iterator->hostname);
+					ast_log(LOG_NOTICE,"#1c.3. There's a dialog...unlinking it...");
+					/* This will also remove references to the registry */
+					dialog_unlink_all(iterator->call, TRUE, TRUE);
+					ast_log(LOG_NOTICE,"#1c.4. Unreffing that dialog...");
+					iterator->call = dialog_unref(iterator->call,"remove iterator->call from registry traversal");
+					/* iterator->call = sip_destroy(iterator->call); */
+				}
+				ast_log(LOG_NOTICE,"#1c.5. About to release iterator's registry lock...");
+				ASTOBJ_UNLOCK(iterator);
+				
 		} while(0));
 
 		ast_log(LOG_NOTICE,"Reload: #1d -- about to destroy all the users\n");

Modified: team/murf/bug11210/include/asterisk/astobj2.h
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/include/asterisk/astobj2.h?view=diff&rev=98271&r1=98270&r2=98271
==============================================================================
--- team/murf/bug11210/include/asterisk/astobj2.h (original)
+++ team/murf/bug11210/include/asterisk/astobj2.h Fri Jan 11 12:48:55 2008
@@ -661,6 +661,10 @@
 	uint version;
 };
 
+/* the flags field can contain F_AO2I_DONTLOCK, which will prevent 
+   ao2_iterator_next calls from locking the container while it
+   searches for the next pointer */
+
 struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags);
 #ifdef REF_DEBUG
 #define ao2_t_iterator_next(arg1, arg2) ao2_iterator_next_debug((arg1), (arg2),  __FILE__, __LINE__, __PRETTY_FUNCTION__)




More information about the asterisk-commits mailing list