All pastes #1043046 Raw Edit

Stuff

public text v1 · immutable
#1043046 ·published 2008-06-09 16:38 UTC
rendered paste body
Index: apps/app_queue.c
===================================================================
--- apps/app_queue.c	(revision 121228)
+++ apps/app_queue.c	(working copy)
@@ -2600,6 +2600,7 @@
 	int callcompletedinsl;
 	struct ao2_iterator memi;
 	struct ast_datastore *datastore;
+	int delay = 1; /* Should we put in a small delay to ensure correct device state of the member? */
 
 	ast_channel_lock(qe->chan);
 	datastore = ast_channel_datastore_find(qe->chan, &dialed_interface_info, NULL);
@@ -2808,6 +2809,7 @@
 		outgoing = NULL;
 		if (announce || qe->parent->reportholdtime || qe->parent->memberdelay) {
 			int res2;
+			delay = 0;
 
 			res2 = ast_autoservice_start(qe->chan);
 			if (!res2) {
@@ -2986,6 +2988,7 @@
 				ast_log(LOG_DEBUG, "app_queue: agi=%s.\n", agi);
 			app = pbx_findapp("agi");
 			if (app) {
+				delay = 0;
 				agiexec = ast_strdupa(agi);
 				ret = pbx_exec(qe->chan, app, agiexec);
 			} else
@@ -3010,6 +3013,13 @@
 		ast_copy_string(oldexten, qe->chan->exten, sizeof(oldexten));
 		time(&callstart);
 
+		/* This helps avoid a race condition between the device state thread and this thread.
+		 * It's possible (likely if using a Local channel or AgentCallbackLogin Agent) that the
+		 * following warning message will be erroneous because agent is just about to change to "in use"
+		 * but the actual state change has not occurred yet.
+		 */
+		if (delay)
+			usleep(100);
 		if (member->status == AST_DEVICE_NOT_INUSE)
 			ast_log(LOG_WARNING, "The device state of this queue member, %s, is still 'Not in Use' when it probably should not be! Please check UPGRADE.txt for correct configuration settings.\n", member->membername);