[asterisk-commits] jpeeler: branch group/multiparking r113873 - /team/group/multiparking/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 9 13:51:36 CDT 2008


Author: jpeeler
Date: Wed Apr  9 13:51:35 2008
New Revision: 113873

URL: http://svn.digium.com/view/asterisk?view=rev&rev=113873
Log:
Fixes problem of timed out parked call not calling caller back and MOH not playing while parked

Modified:
    team/group/multiparking/main/features.c

Modified: team/group/multiparking/main/features.c
URL: http://svn.digium.com/view/asterisk/team/group/multiparking/main/features.c?view=diff&rev=113873&r1=113872&r2=113873
==============================================================================
--- team/group/multiparking/main/features.c (original)
+++ team/group/multiparking/main/features.c Wed Apr  9 13:51:35 2008
@@ -200,7 +200,7 @@
 static struct ast_parkinglot *parkinglot_addref(struct ast_parkinglot *parkinglot);
 static void parkinglot_unref(struct ast_parkinglot *parkinglot);
 static void parkinglot_destroy(struct ast_parkinglot *ruin);
-int manage_parkinglot(struct ast_parkinglot *curlot, fd_set *rfds, fd_set *efds, fd_set *nrfds, fd_set *nefds);
+int manage_parkinglot(struct ast_parkinglot *curlot, fd_set *rfds, fd_set *efds, fd_set *nrfds, fd_set *nefds, int *fs, int *max);
 int ast_park_call_full(struct ast_channel *chan, struct ast_channel *peer, int timeout, int *extout, struct ast_parkinglot *parkinglot); /* TODO: this wasn't defined anywhere */
 struct ast_parkinglot *find_parkinglot(const char *name);
 
@@ -2241,15 +2241,15 @@
 }
 
 /*! \brief Run management on parkinglots, collad once per parkinglot */
-int manage_parkinglot(struct ast_parkinglot *curlot, fd_set *rfds, fd_set *efds, fd_set *nrfds, fd_set *nefds)
-{
-
-	int ms = -1;	/* select timeout, uninitialized */
-	int max = -1;	/* max fd, none there yet */
+int manage_parkinglot(struct ast_parkinglot *curlot, fd_set *rfds, fd_set *efds, fd_set *nrfds, fd_set *nefds, int *ms, int *max)
+{
+
 	struct parkeduser *pu;
 	int res = 0;
-
-	parkinglot_addref(curlot);
+	char parkingslot[AST_MAX_EXTENSION];
+
+	/* jpeeler: this either needs to be moved or is not necessary: */
+	/*parkinglot_addref(curlot);*/
 	ASTOBJ_WRLOCK(curlot);
 	/* Lock parking list */
 	AST_LIST_LOCK(&curlot->parkings);
@@ -2307,9 +2307,8 @@
 					set_c_e_p(chan, pu->parkinglot->parking_con_dial, peername_flat, 1);
 				} else {
 					ast_log(LOG_WARNING, "now going to parkedcallstimeout,s,1 | ps is %d\n",pu->parkingnum);
-					//XXX: Why is this commented out ? it should not be!
-					//snprintf(parkingslot, sizeof(parkingslot), "%d", pu->parkingnum);
-					//pbx_builtin_setvar_helper(chan, "PARKINGSLOT", parkingslot);
+					snprintf(parkingslot, sizeof(parkingslot), "%d", pu->parkingnum);
+					pbx_builtin_setvar_helper(chan, "PARKINGSLOT", parkingslot);
 					set_c_e_p(chan, "parkedcallstimeout", peername_flat, 1);
 				}
 			} else {
@@ -2340,19 +2339,9 @@
 			for (x = 0; x < AST_MAX_FDS; x++) {
 				struct ast_frame *f;
 
-				/*if ((chan->fds[x] == -1) && (!FD_ISSET(chan->fds[x], rfds) && !FD_ISSET(pu->chan->fds[x], efds))) 
+				if ((chan->fds[x] == -1) && (!FD_ISSET(chan->fds[x], rfds) && !FD_ISSET(pu->chan->fds[x], efds))) 
 					continue;
-				*/
-				/* TODO: not sure why splitting this up stops a segfault */
-				if (chan->fds[x] == -1) 
-					continue;
-
-				if (!FD_ISSET(chan->fds[x], rfds))
-					continue;
-
-				if (!FD_ISSET(pu->chan->fds[x], efds))
-					continue;
-
+				
 				if (FD_ISSET(chan->fds[x], efds))
 					ast_set_flag(chan, AST_FLAG_EXCEPTION);
 				else
@@ -2400,13 +2389,13 @@
 					if (chan->fds[x] > -1) {
 						FD_SET(chan->fds[x], nrfds);
 						FD_SET(chan->fds[x], nefds);
-						if (chan->fds[x] > max)
-							max = chan->fds[x];
+						if (chan->fds[x] > *max)
+							*max = chan->fds[x];
 					}
 				}
 				/* Keep track of our shortest wait */
-				if (tms < ms || ms < 0)
-					ms = tms;
+				if (tms < *ms || *ms < 0)
+					*ms = tms;
 			}
 		}
 	}
@@ -2427,7 +2416,6 @@
 */
 static void *do_parking_thread(void *ignore)
 {
-	int ms = -1;
 	fd_set rfds, efds;	/* results from previous select, to be preserved across loops. */
 	fd_set nrfds, nefds;	/* args for the next select */
 	FD_ZERO(&nrfds);
@@ -2435,10 +2423,11 @@
 
 	for (;;) {
 		int res = 0;
+		int ms = -1;	/* select timeout, uninitialized */
+		int max = -1;	/* max fd, none there yet */
 		ASTOBJ_CONTAINER_TRAVERSE(&parkinglots, 1, do {
-			
 			ASTOBJ_WRLOCK(iterator);
-			res = manage_parkinglot(iterator, &rfds, &efds, &nrfds, &nefds);
+			res = manage_parkinglot(iterator, &rfds, &efds, &nrfds, &nefds, &ms, &max);
 			ASTOBJ_UNLOCK(iterator);
 		} while (0) );
 
@@ -2446,8 +2435,6 @@
 		efds = nefds;
 		{
 			struct timeval tv = ast_samp2tv(ms, 1000);
-			int ms = -1;	/* select timeout, uninitialized */
-			int max = -1;	/* max fd, none there yet */
 			/* Wait for something to happen */
 			ast_select(max + 1, &rfds, NULL, &efds, (ms > -1) ? &tv : NULL);
 		}
@@ -2751,6 +2738,10 @@
 			parkinglot->parkfindnext = (!strcasecmp(confvar->value, "next"));
 		}
 		confvar = confvar->next;
+	}
+	/* make sure parkingtime is set if not specified */
+	if (parkinglot->parkingtime == 0) {
+		parkinglot->parkingtime = DEFAULT_PARK_TIME;
 	}
 
 	if (!var) {	/* Default parking lot */




More information about the asterisk-commits mailing list