[asterisk-commits] russell: branch 1.4 r64353 - /branches/1.4/res/res_features.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon May 14 14:16:40 MST 2007


Author: russell
Date: Mon May 14 16:16:39 2007
New Revision: 64353

URL: http://svn.digium.com/view/asterisk?view=rev&rev=64353
Log:
When someone requests a specific parking space using the PARKINGEXTEN variable,
ensure that no other caller is already there.
(issue #9723, reported by mdu113, patch by me)

Modified:
    branches/1.4/res/res_features.c

Modified: branches/1.4/res/res_features.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/res/res_features.c?view=diff&rev=64353&r1=64352&r2=64353
==============================================================================
--- branches/1.4/res/res_features.c (original)
+++ branches/1.4/res/res_features.c Mon May 14 16:16:39 2007
@@ -305,6 +305,23 @@
 		return AST_DEVICE_INUSE;
 }
 
+/*!
+ * \brief Check to see if a parking space is in use
+ * \return non-zero if in use, zero if not in use
+ * \note Assumes parking_lock is locked
+ */
+static int check_parking_space_inuse(int space)
+{
+	struct parkeduser *pu;
+
+	for (pu = parkinglot; pu; pu = pu->next) {
+		if (pu->parkingnum == space)
+			return 1;
+	}
+
+	return 0;
+}
+
 /*! \brief Park a call 
  	\note We put the user in the parking list, then wake up the parking thread to be sure it looks
 	after these channels too */
@@ -330,6 +347,12 @@
 		}
 		ast_copy_string(pu->parkingexten, parkingexten, sizeof(pu->parkingexten));
 		x = atoi(parkingexten);
+		if (check_parking_space_inuse(x)) {
+			ast_mutex_unlock(&parking_lock);
+			free(pu);
+			ast_log(LOG_WARNING, "Requested parking space %d via PARKINGEXTEN, but it is in use!\n", x);
+			return -1;
+		}
 	} else {
 		/* Select parking space within range */
 		parking_range = parking_stop - parking_start+1;



More information about the asterisk-commits mailing list