Index: asterisk/apps/app_queue.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_queue.c,v
retrieving revision 1.32
diff -u -r1.32 app_queue.c
--- asterisk/apps/app_queue.c	23 Aug 2003 02:11:44 -0000	1.32
+++ asterisk/apps/app_queue.c	28 Aug 2003 20:50:46 -0000
@@ -159,6 +159,7 @@
 	int dead;				/* Whether this queue is dead or not */
 	int retry;				/* Retry calling everyone after this amount of time */
 	int timeout;			/* How long to wait for an answer */
+        int queuetimeout;               /* How long to wait for an agent */
 	
 	/* Queue strategy things */
 	
@@ -1100,6 +1101,8 @@
 	char *options = NULL;
 	char *url = NULL;
 	char *announceoverride = NULL;
+        time_t now;
+        time_t now_time;
 	
 	/* Our queue entry */
 	struct queue_ent qe;
@@ -1170,6 +1173,22 @@
 				}
 				if (res && valid_exit(&qe, res))
 					break;
+
+                                if (qe.parent->queuetimeout) {
+                                        now_time = time(&now);
+                                        if (!res && (now_time - qe.start) >= qe.parent->queuetimeout) {
+                                                if (valid_exit(&qe, 115)) {
+							ast_verbose(VERBOSE_PREFIX_3 "queuetimeout exceeded (%d), valid exten avail, setting res = 1\n", qe.parent->queuetimeout);
+                                                        res = 1;
+                                                        break;
+                                                } else {
+							ast_verbose(VERBOSE_PREFIX_3 "queuetimeout exceeded (%d), no valid exten, exiting\n", qe.parent->queuetimeout);
+                                                        res = -1;
+                                                        break;
+                                                }
+                                        }
+                                }
+
 			}
 		}
 		/* Don't allow return code > 0 */
@@ -1284,6 +1303,8 @@
 						strncpy(q->context, var->value, sizeof(q->context) - 1);
 					} else if (!strcasecmp(var->name, "timeout")) {
 						q->timeout = atoi(var->value);
+                                        } else if (!strcasecmp(var->name, "queuetimeout")) {
+                                                q->queuetimeout = atoi(var->value);
 					} else if (!strcasecmp(var->name, "retry")) {
 						q->retry = atoi(var->value);
 					} else if (!strcasecmp(var->name, "maxlen")) {
