[asterisk-commits] trunk r11312 - /trunk/channels/chan_iax2.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Feb 27 21:20:14 MST 2006


Author: markster
Date: Mon Feb 27 22:20:14 2006
New Revision: 11312

URL: http://svn.digium.com/view/asterisk?rev=11312&view=rev
Log:
Keep track of the function we're in the middle of doing

Modified:
    trunk/channels/chan_iax2.c

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=11312&r1=11311&r2=11312&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Mon Feb 27 22:20:14 2006
@@ -103,6 +103,10 @@
 /* Define SCHED_MULTITHREADED to run the scheduler in a special
    multithreaded mode. */
 #define SCHED_MULTITHREADED
+
+/* Define DEBUG_SCHED_MULTITHREADED to keep track of where each
+   thread is actually doing. */
+#define DEBUG_SCHED_MULTITHREAD
 
 #ifdef NEWJB
 #include "../jitterbuf.h"
@@ -680,6 +684,9 @@
 	void (*schedfunc)(void *);
 	void *scheddata;
 #endif
+#ifdef DEBUG_SCHED_MULTITHREAD
+	char curfunc[80];
+#endif	
 	int actions;
 	int halt;
 	pthread_t threadid;
@@ -816,7 +823,7 @@
 }
 
 #ifdef SCHED_MULTITHREADED
-static int schedule_action(void (*func)(void *data), void *data)
+static int __schedule_action(void (*func)(void *data), void *data, const char *funcname)
 {
 	struct iax2_thread *thread;
 	static time_t lasterror;
@@ -826,6 +833,9 @@
 		thread->schedfunc = func;
 		thread->scheddata = data;
 		thread->iostate = IAX_IOSTATE_SCHEDREADY;
+#ifdef DEBUG_SCHED_MULTITHREAD
+		ast_copy_string(thread->curfunc, funcname, sizeof(thread->curfunc));
+#endif
 		pthread_kill(thread->threadid, SIGURG);
 		return 0;
 	}
@@ -835,6 +845,7 @@
 	lasterror = t;
 	return -1;
 }
+#define schedule_action(func, data) __schedule_action(func, data, __PRETTY_FUNCTION__)
 #endif
 
 static void __send_ping(void *data)
@@ -4416,14 +4427,26 @@
 	time(&t);
 	ast_cli(fd, "Idle Threads:\n");
 	ASTOBJ_CONTAINER_TRAVERSE(&idlelist, 1, {
-		ast_cli(fd, "Thread %d: state %d, last update: %d seconds ago, %d actions handled, refcnt = %d\n", 
-			iterator->threadnum, iterator->iostate, (int)(t - iterator->checktime), iterator->actions, iterator->refcount);
+		ast_cli(fd, "Thread %d: state=%d, update=%d, actions=%d, refcnt=%d, func ='%s'\n", 
+			iterator->threadnum, iterator->iostate, (int)(t - iterator->checktime), iterator->actions, iterator->refcount,
+#ifdef DEBUG_SCHED_MULTITHREAD
+		iterator->curfunc
+#else
+		""
+#endif
+		);
 		threadcount++;
 	});
 	ast_cli(fd, "Active Threads:\n");
 	ASTOBJ_CONTAINER_TRAVERSE(&activelist, 1, {
-		ast_cli(fd, "Thread %d: state %d, last update: %d seconds ago, %d actions handled, refcnt = %d\n", 
-			iterator->threadnum, iterator->iostate, (int)(t - iterator->checktime), iterator->actions, iterator->refcount);
+		ast_cli(fd, "Thread %d: state=%d, update=%d, actions=%d, refcnt=%d, func ='%s'\n", 
+			iterator->threadnum, iterator->iostate, (int)(t - iterator->checktime), iterator->actions, iterator->refcount,
+#ifdef DEBUG_SCHED_MULTITHREAD
+		iterator->curfunc
+#else
+		""
+#endif
+			);
 		threadcount++;
 	});
 	ast_cli(fd, "%d of %d threads accounted for\n", threadcount, iaxthreadcount);
@@ -6467,6 +6490,9 @@
 		}
 		/* Mark as ready and send on its way */
 		thread->iostate = IAX_IOSTATE_READY;
+#ifdef DEBUG_SCHED_MULTITHREAD
+		ast_copy_string(thread->curfunc, "socket_process", sizeof(thread->curfunc));
+#endif
 		pthread_kill(thread->threadid, SIGURG);
 	} else {
 		time(&t);
@@ -7874,6 +7900,9 @@
 		}
 		time(&thread->checktime);
 		thread->iostate = IAX_IOSTATE_IDLE;
+#ifdef DEBUG_SCHED_MULTITHREAD
+		thread->curfunc[0]='\0';
+#endif		
 		ASTOBJ_CONTAINER_UNLINK(&activelist, thread);
 		ASTOBJ_CONTAINER_LINK_END(&idlelist, thread);
 		/* Make a copy so we don't lose thread, but if 



More information about the asterisk-commits mailing list