[svn-commits] oej: branch oej/statechange-7816 r48145 - /team/oej/statechange-7816/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu Nov 30 10:59:59 MST 2006


Author: oej
Date: Thu Nov 30 11:59:59 2006
New Revision: 48145

URL: http://svn.digium.com/view/asterisk?view=rev&rev=48145
Log:
Adding debug logging 

Modified:
    team/oej/statechange-7816/devicestate.c

Modified: team/oej/statechange-7816/devicestate.c
URL: http://svn.digium.com/view/asterisk/team/oej/statechange-7816/devicestate.c?view=diff&rev=48145&r1=48144&r2=48145
==============================================================================
--- team/oej/statechange-7816/devicestate.c (original)
+++ team/oej/statechange-7816/devicestate.c Thu Nov 30 11:59:59 2006
@@ -62,8 +62,11 @@
 
 struct state_change {
 	AST_LIST_ENTRY(state_change) list;
+	int id;
 	char device[1];
 };
+
+int changeid = 0;	/*! Temporary counter */
 
 static AST_LIST_HEAD_STATIC(state_changes, state_change);
 
@@ -203,13 +206,17 @@
 	tmp = strrchr(device, '-');
 	if (tmp)
 		*tmp = '\0';
-	if (change_thread != AST_PTHREADT_NULL)
+	if (change_thread != AST_PTHREADT_NULL) {
 		change = calloc(1, sizeof(*change) + strlen(device));
+		change->id = ++changeid;
+	}
+
 
 	if (!change) {
 		/* we could not allocate a change struct, or */
 		/* there is no background thread, so process the change now */
 		do_state_change(device);
+		ast_log(LOG_DEBUG, "::: Devicestate ::: DIRECT Changing state for device %s\n", device);
 	} else {
 		/* queue the change */
 		strcpy(change->device, device);
@@ -219,6 +226,7 @@
 			/* the list was empty, signal the thread */
 			ast_cond_signal(&change_pending);
 		AST_LIST_UNLOCK(&state_changes);
+		ast_log(LOG_DEBUG, "::: Devicestate ::: QUEUED state change for device %s - qid %d\n", device, change->id);
 	}
 
 	return 1;
@@ -255,12 +263,14 @@
 		if (cur) {
 			/* we got an entry, so unlock the list while we process it */
 			AST_LIST_UNLOCK(&state_changes);
+			ast_log(LOG_DEBUG, "::: Devicestate ::: PROCESSING queued state change for device %s - id %d\n", cur->device, cur->id);
 			do_state_change(cur->device);
 			free(cur);
 			AST_LIST_LOCK(&state_changes);
 		} else {
 			/* there was no entry, so atomically unlock the list and wait for
 			   the condition to be signalled (returns with the lock held) */
+			ast_log(LOG_DEBUG, "::: Devicestate ::: Thread going into wait state, pending future changes. zzzzzzzzzzzzzz\n");
 			ast_cond_wait(&change_pending, &state_changes.lock);
 		}
 	}
@@ -276,6 +286,7 @@
 		ast_log(LOG_ERROR, "Unable to start device state change thread.\n");
 		return -1;
 	}
+	ast_log(LOG_DEBUG, "::: Devicestate ::: Devicestate thread launched successfully. Ready for a changing time!!!\n");
 
 	return 0;
 }



More information about the svn-commits mailing list