[asterisk-commits] oej: branch group/multiparking r104062 - /team/group/multiparking/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Feb 23 11:08:59 CST 2008


Author: oej
Date: Sat Feb 23 11:08:58 2008
New Revision: 104062

URL: http://svn.digium.com/view/asterisk?view=rev&rev=104062
Log:
Fixes

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=104062&r1=104061&r2=104062
==============================================================================
--- team/group/multiparking/main/features.c (original)
+++ team/group/multiparking/main/features.c Sat Feb 23 11:08:58 2008
@@ -2470,6 +2470,22 @@
 	return NULL;	/* Never reached */
 }
 
+/*! \brief Find parkinglot by name */
+struct ast_parkinglot *find_parkinglot(const char *name)
+{
+	struct ast_parkinglot *parkinglot = NULL;
+	
+	if (ast_strlen_zero(name))
+		return NULL;
+
+	parkinglot = ASTOBJ_CONTAINER_FIND(&parkinglots, name);
+
+	if (parkinglot && option_debug)
+		ast_log(LOG_DEBUG, "Found Parkinglot: %s\n", parkinglot->name);
+
+	return parkinglot;
+}
+
 /*! \brief Park a call */
 static int park_call_exec(struct ast_channel *chan, void *data)
 {
@@ -2532,30 +2548,33 @@
 	struct parkeduser *pu;
 	struct ast_context *con;
 	const char *parkinglotname;
+	struct ast_parkinglot *parkinglot;
 	int park = 0;
 	struct ast_bridge_config config;
 
 	if (data)
 		park = atoi((char *)data);
 
-	AST_LIST_LOCK(&parkings);
-	AST_LIST_TRAVERSE_SAFE_BEGIN(&parkings, pu, list) {
+	parkinglot= find_parkinglot(findparkinglotname(chan)); 	
+
+	AST_LIST_LOCK(&parkinglot->parkings);
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&parkinglot->parkings, pu, list) {
 		if (!data || pu->parkingnum == park) {
 			AST_LIST_REMOVE_CURRENT(list);
 			break;
 		}
 	}
 	AST_LIST_TRAVERSE_SAFE_END
-	AST_LIST_UNLOCK(&parkings);
+	AST_LIST_UNLOCK(&parkinglot->parkings);
 
 	if (pu) {
 		peer = pu->chan;
-		con = ast_context_find(parking_con);
+		con = ast_context_find(parkinglot->parking_con);
 		if (con) {
 			if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL))
 				ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
 			else
-				notify_metermaids(pu->parkingexten, parking_con, AST_DEVICE_NOT_INUSE);
+				notify_metermaids(pu->parkingexten, parkinglot->parking_con, AST_DEVICE_NOT_INUSE);
 		} else
 			ast_log(LOG_WARNING, "Whoa, no parking context?\n");
 
@@ -2575,6 +2594,8 @@
 	/* JK02: it helps to answer the channel if not already up */
 	if (chan->_state != AST_STATE_UP)
 		ast_answer(chan);
+
+	AST_OBJ_UNLOCK(parkinglot);
 
 	if (peer) {
 		/* Play a courtesy to the source(s) configured to prefix the bridge connecting */




More information about the asterisk-commits mailing list