[asterisk-commits] mjordan: branch mjordan/1.8_instrumented r361947 - /team/mjordan/1.8_instrume...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 11 14:47:25 CDT 2012


Author: mjordan
Date: Wed Apr 11 14:47:21 2012
New Revision: 361947

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=361947
Log:
Add a bunch of printfs to determine early quit/register thread issues

Lots of printfs...

Modified:
    team/mjordan/1.8_instrumented/main/asterisk.c

Modified: team/mjordan/1.8_instrumented/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/1.8_instrumented/main/asterisk.c?view=diff&rev=361947&r1=361946&r2=361947
==============================================================================
--- team/mjordan/1.8_instrumented/main/asterisk.c (original)
+++ team/mjordan/1.8_instrumented/main/asterisk.c Wed Apr 11 14:47:21 2012
@@ -400,15 +400,18 @@
 		return;
 	new->id = pthread_self();
 	new->name = name; /* steal the allocated memory for the thread name */
+	printf("Registering thread %s with ID %d [%d]\n", new->name, new->id, __LINE__);
 	AST_RWLIST_WRLOCK(&thread_list);
 	AST_RWLIST_INSERT_HEAD(&thread_list, new, list);
 	AST_RWLIST_UNLOCK(&thread_list);
+	printf("Done registering thread %s with ID %d [%d]\n", new->name, new->id, __LINE__);
 }
 
 void ast_unregister_thread(void *id)
 {
 	struct thread_list_t *x;
 
+	printf("Attempting to gain thread list lock on thread ID %d [%d]\n", pthread_self(), __LINE__);
 	AST_RWLIST_WRLOCK(&thread_list);
 	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&thread_list, x, list) {
 		if ((void *) x->id == id) {
@@ -418,6 +421,7 @@
 	}
 	AST_RWLIST_TRAVERSE_SAFE_END;
 	AST_RWLIST_UNLOCK(&thread_list);
+	printf("Released thread list lock on thread ID %d [%d]\n", pthread_self(), __LINE__);
 	if (x) {
 		ast_free(x->name);
 		ast_free(x);
@@ -522,13 +526,14 @@
 	case CLI_GENERATE:
 		return NULL;
 	}
-
+	printf("Attempting to gain thread list lock on thread ID %d [%d]\n", pthread_self(), __LINE__);
 	AST_RWLIST_RDLOCK(&thread_list);
 	AST_RWLIST_TRAVERSE(&thread_list, cur, list) {
 		ast_cli(a->fd, "%p %s\n", (void *)cur->id, cur->name);
 		count++;
 	}
         AST_RWLIST_UNLOCK(&thread_list);
+    printf("Released thread list lock on thread ID %d [%d]\n", pthread_self(), __LINE__);
 	ast_cli(a->fd, "%d threads listed.\n", count);
 	return CLI_SUCCESS;
 }
@@ -1621,6 +1626,7 @@
 
 static void quit_handler(int num, shutdown_nice_t niceness, int restart)
 {
+	printf("Going into quit handler on thread ID %d\n", pthread_self());
 	if (can_safely_quit(niceness, restart)) {
 		really_quit(num, niceness, restart);
 		/* No one gets here. */
@@ -1696,6 +1702,7 @@
 
 static void really_quit(int num, shutdown_nice_t niceness, int restart)
 {
+	printf("Starting really quit on thread ID %d\n", pthread_self());
 	if (niceness >= SHUTDOWN_NICE) {
 		ast_module_shutdown();
 	}
@@ -1752,7 +1759,7 @@
 		if (option_verbose || ast_opt_console)
 			ast_verbose("Asterisk is now restarting...\n");
 		restartnow = 1;
-
+		printf("Killing the logger on thread ID %d\n", pthread_self());
 		/* close logger */
 		close_logger();
 
@@ -1766,6 +1773,7 @@
 			execvp(_argv[0], _argv);
 	
 	} else {
+		printf("Killing the logger on thread ID %d\n", pthread_self());
 		/* close logger */
 		close_logger();
 	}
@@ -1784,10 +1792,12 @@
 	}
 	/* There is no need to restore the signal handler here, since the app
 	 * is going to exit */
+	printf("In __quit_handler\n");
 }
 
 static void __remote_quit_handler(int num)
 {
+	printf("Setting signal flags that we need a quit\n");
 	sig_flags.need_quit = 1;
 }
 
@@ -1878,6 +1888,7 @@
 	}
 	if ((strncasecmp(s, "quit", 4) == 0 || strncasecmp(s, "exit", 4) == 0) &&
 	    (s[4] == '\0' || isspace(s[4]))) {
+		printf("Starting quit handler in remoteconsolehandler [%s]\n", s);
 		quit_handler(0, SHUTDOWN_FAST, 0);
 		ret = 1;
 	}
@@ -1931,6 +1942,7 @@
 
 	if (a->argc != e->args)
 		return CLI_SHOWUSAGE;
+	printf("Calling quit handler for handle_stop_now\n");
 	quit_handler(0, SHUTDOWN_NORMAL, 0 /* not restart */);
 	return CLI_SUCCESS;
 }
@@ -1951,6 +1963,7 @@
 
 	if (a->argc != e->args)
 		return CLI_SHOWUSAGE;
+	printf("Calling quit handler from handle_stop_gracefully\n");
 	quit_handler(0, SHUTDOWN_NICE, 0 /* no restart */);
 	return CLI_SUCCESS;
 }
@@ -1971,6 +1984,7 @@
 	if (a->argc != e->args)
 		return CLI_SHOWUSAGE;
 	ast_cli(a->fd, "Waiting for inactivity to perform halt\n");
+	printf("Calling quit handler from stop when convenient\n");
 	quit_handler(0, SHUTDOWN_REALLY_NICE, 0 /* don't restart */);
 	return CLI_SUCCESS;
 }
@@ -1991,6 +2005,7 @@
 
 	if (a->argc != e->args)
 		return CLI_SHOWUSAGE;
+	printf("Calling quit handler from core restart now\n");
 	quit_handler(0, SHUTDOWN_NORMAL, 1 /* restart */);
 	return CLI_SUCCESS;
 }
@@ -2011,6 +2026,7 @@
 
 	if (a->argc != e->args)
 		return CLI_SHOWUSAGE;
+	printf("Calling quit handler from restart gracefully\n");
 	quit_handler(0, SHUTDOWN_NICE, 1 /* restart */);
 	return CLI_SUCCESS;
 }
@@ -2233,6 +2249,7 @@
 			if (res < 1) {
 				fprintf(stderr, "\nDisconnected from Asterisk server\n");
 				if (!ast_opt_reconnect) {
+					printf("Disconnected from Asterisk server, shutting down fast\n");
 					quit_handler(0, SHUTDOWN_FAST, 0);
 				} else {
 					int tries;
@@ -2253,6 +2270,7 @@
 					}
 					if (tries >= 30 * reconnects_per_second) {
 						fprintf(stderr, "Failed to reconnect for 30 seconds.  Quitting.\n");
+						printf ("Failed to reconnect, shutting down fast\n");
 						quit_handler(0, SHUTDOWN_FAST, 0);
 					}
 				}
@@ -3954,6 +3972,7 @@
 
 		for (;;) {
 			if (sig_flags.need_quit || sig_flags.need_quit_handler) {
+				printf("Detected signal that we need to shut down now\n");
 				quit_handler(0, SHUTDOWN_FAST, 0);
 				break;
 			}




More information about the asterisk-commits mailing list