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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 21 17:40:31 CDT 2008


Author: jpeeler
Date: Mon Apr 21 17:40:30 2008
New Revision: 114455

URL: http://svn.digium.com/view/asterisk?view=rev&rev=114455
Log:
moved some stuff into ast_parkinglot and removed some unnecessary locking

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=114455&r1=114454&r2=114455
==============================================================================
--- team/group/multiparking/main/features.c (original)
+++ team/group/multiparking/main/features.c Mon Apr 21 17:40:30 2008
@@ -87,11 +87,6 @@
 
 static char *parkedcall = "ParkedCall";
 
-/*! \todo Should this move into the parking lot ??? */
-static int parkaddhints = 0;                               /*!< Add parking hints automatically */
-static int parkedcalltransfers = 0;                        /*!< Enable DTMF based transfers on bridge when picking up parked calls */
-static int parkedcallreparking = 0;                        /*!< Enable DTMF based parking on bridge when picking up parked calls */
-
 static char pickup_ext[AST_MAX_EXTENSION];                 /*!< Call pickup extension */
 
 /*! \brief Description of one parked call, added to a list while active, then removed.
@@ -113,8 +108,6 @@
 	AST_LIST_ENTRY(parkeduser) list;
 };
 
-AST_LIST_HEAD(parkinglot_parklist, parkeduser);
-
 /*! \brief Structure for parking lots which are put in a container. */
 struct ast_parkinglot {
 	char name[AST_MAX_CONTEXT];
@@ -126,7 +119,10 @@
 	int parkfindnext;
 	int parkingtime;				/*!< Default parking time */
 	char mohclass[MAX_MUSICCLASS];                  /*!< Music class used for parking */
-	struct parkinglot_parklist parkings;		/*!< List of active parkings in this parkinglot */
+	int parkaddhints;                               /*!< Add parking hints automatically */
+	int parkedcalltransfers;                        /*!< Enable DTMF based transfers on bridge when picking up parked calls */
+	int parkedcallreparking;                        /*!< Enable DTMF based parking on bridge when picking up parked calls */
+	AST_LIST_HEAD(parkinglot_parklist, parkeduser) parkings; /*!< List of active parkings in this parkinglot */
 };
 
 /*! \brief The list of parking lots configured. Always at least one  - the default parking lot */
@@ -456,8 +452,6 @@
 		return -1;
 	}
 
-	ao2_lock(parkinglot);
-
 	/* Lock parking list */
 	AST_LIST_LOCK(&parkinglot->parkings);
 	/* Check for channel variable PARKINGEXTEN */
@@ -468,7 +462,6 @@
 			parkinglot_unref(parkinglot);
 			ast_free(pu);
 			ast_log(LOG_WARNING, "Requested parking extension already exists: %s@%s\n", parkingexten, parkinglot->parking_con);
-			ao2_unlock(parkinglot);
 			return 1;	/* Continue execution if possible */
 		}
 		ast_copy_string(pu->parkingexten, parkingexten, sizeof(pu->parkingexten));
@@ -491,7 +484,6 @@
 			ast_free(pu);
 			AST_LIST_UNLOCK(&parkinglot->parkings);
 			parkinglot_unref(parkinglot);
-			ao2_unlock(parkinglot);
 			return -1;
 		}
 		/* Set pointer for next parking */
@@ -532,7 +524,6 @@
 	if (peer == chan) 
 		pu->notquiteyet = 1;
 	AST_LIST_UNLOCK(&parkinglot->parkings);
-	ao2_unlock(parkinglot);
 
 	/* Wake up the (presumably select()ing) thread */
 	pthread_kill(parking_thread, SIGURG);
@@ -2266,7 +2257,6 @@
 
 	/* TODO: I believe this reference increase is not necessary since the iterator in the calling function already did so */
 	//parkinglot_addref(curlot);
-	ao2_lock(curlot);
 	/* Lock parking list */
 	AST_LIST_LOCK(&curlot->parkings);
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&curlot->parkings, pu, list) {
@@ -2417,7 +2407,6 @@
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
 	AST_LIST_UNLOCK(&curlot->parkings);
-	ao2_unlock(curlot);
 	return res;
 }
 
@@ -2635,13 +2624,13 @@
 		pbx_builtin_setvar_helper(chan, "PARKEDCHANNEL", peer->name);
 		ast_cdr_setdestchan(chan->cdr, peer->name);
 		memset(&config, 0, sizeof(struct ast_bridge_config));
-		if ((parkedcalltransfers == AST_FEATURE_FLAG_BYCALLEE) || (parkedcalltransfers == AST_FEATURE_FLAG_BYBOTH))
+		if ((parkinglot->parkedcalltransfers == AST_FEATURE_FLAG_BYCALLEE) || (parkinglot->parkedcalltransfers == AST_FEATURE_FLAG_BYBOTH))
 			ast_set_flag(&(config.features_callee), AST_FEATURE_REDIRECT);
-		if ((parkedcalltransfers == AST_FEATURE_FLAG_BYCALLER) || (parkedcalltransfers == AST_FEATURE_FLAG_BYBOTH))
+		if ((parkinglot->parkedcalltransfers == AST_FEATURE_FLAG_BYCALLER) || (parkinglot->parkedcalltransfers == AST_FEATURE_FLAG_BYBOTH))
 			ast_set_flag(&(config.features_caller), AST_FEATURE_REDIRECT);
-		if ((parkedcallreparking == AST_FEATURE_FLAG_BYCALLEE) || (parkedcallreparking == AST_FEATURE_FLAG_BYBOTH))
+		if ((parkinglot->parkedcallreparking == AST_FEATURE_FLAG_BYCALLEE) || (parkinglot->parkedcallreparking == AST_FEATURE_FLAG_BYBOTH))
 			ast_set_flag(&(config.features_callee), AST_FEATURE_PARKCALL);
-		if ((parkedcallreparking == AST_FEATURE_FLAG_BYCALLER) || (parkedcallreparking == AST_FEATURE_FLAG_BYBOTH))
+		if ((parkinglot->parkedcallreparking == AST_FEATURE_FLAG_BYCALLER) || (parkinglot->parkedcallreparking == AST_FEATURE_FLAG_BYBOTH))
 			ast_set_flag(&(config.features_caller), AST_FEATURE_PARKCALL);
 		res = ast_bridge_call(chan, peer, &config);
 
@@ -2885,9 +2874,9 @@
 	adsipark = 0;
 	comebacktoorigin = 1;
 
-	parkaddhints = 0;		/*! MVANBAAK-OEJ: Should these be move to the parkinglot structure????? */
-	parkedcalltransfers = 0;
-	parkedcallreparking = 0;
+	default_parkinglot->parkaddhints = 0;
+	default_parkinglot->parkedcalltransfers = 0;
+	default_parkinglot->parkedcallreparking = 0;
 
 	transferdigittimeout = DEFAULT_TRANSFER_DIGIT_TIMEOUT;
 	featuredigittimeout = DEFAULT_FEATURE_DIGIT_TIMEOUT;
@@ -2924,21 +2913,21 @@
 		} else if (!strcasecmp(var->name, "findslot")) {
 			default_parkinglot->parkfindnext = (!strcasecmp(var->value, "next"));
 		} else if (!strcasecmp(var->name, "parkinghints")) {
-			parkaddhints = ast_true(var->value);
+			default_parkinglot->parkaddhints = ast_true(var->value);
 		} else if (!strcasecmp(var->name, "parkedcalltransfers")) {
 			if (!strcasecmp(var->value, "both"))
-				parkedcalltransfers = AST_FEATURE_FLAG_BYBOTH;
+				default_parkinglot->parkedcalltransfers = AST_FEATURE_FLAG_BYBOTH;
 			else if (!strcasecmp(var->value, "caller"))
-				parkedcalltransfers = AST_FEATURE_FLAG_BYCALLER;
+				default_parkinglot->parkedcalltransfers = AST_FEATURE_FLAG_BYCALLER;
 			else if (!strcasecmp(var->value, "callee"))
-				parkedcalltransfers = AST_FEATURE_FLAG_BYCALLEE;
+				default_parkinglot->parkedcalltransfers = AST_FEATURE_FLAG_BYCALLEE;
 		} else if (!strcasecmp(var->name, "parkedcallreparking")) {
 			if (!strcasecmp(var->value, "both"))
-				parkedcalltransfers = AST_FEATURE_FLAG_BYBOTH;
+				default_parkinglot->parkedcallreparking = AST_FEATURE_FLAG_BYBOTH;
 			else if (!strcasecmp(var->value, "caller"))
-				parkedcalltransfers = AST_FEATURE_FLAG_BYCALLER;
+				default_parkinglot->parkedcallreparking = AST_FEATURE_FLAG_BYCALLER;
 			else if (!strcasecmp(var->value, "callee"))
-				parkedcalltransfers = AST_FEATURE_FLAG_BYCALLEE;
+				default_parkinglot->parkedcallreparking = AST_FEATURE_FLAG_BYCALLEE;
 		} else if (!strcasecmp(var->name, "adsipark")) {
 			adsipark = ast_true(var->value);
 		} else if (!strcasecmp(var->name, "transferdigittimeout")) {
@@ -3138,7 +3127,7 @@
 		return -1;
 	}
 	res = ast_add_extension2(con, 1, ast_parking_ext(), 1, NULL, NULL, parkcall, NULL, NULL, registrar);
-	if (parkaddhints)
+	if (default_parkinglot->parkaddhints)
 		park_add_hints(default_parkinglot->parking_con, default_parkinglot->parking_start, default_parkinglot->parking_stop);
 	if (!res)
 		notify_metermaids(ast_parking_ext(), default_parkinglot->parking_con, AST_DEVICE_INUSE);




More information about the asterisk-commits mailing list