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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 11 17:32:24 CDT 2008


Author: jpeeler
Date: Fri Apr 11 17:32:24 2008
New Revision: 114082

URL: http://svn.digium.com/view/asterisk?view=rev&rev=114082
Log:
checkpoint, added refcount debugging information, fixed some comments

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=114082&r1=114081&r2=114082
==============================================================================
--- team/group/multiparking/main/features.c (original)
+++ team/group/multiparking/main/features.c Fri Apr 11 17:32:24 2008
@@ -1,6 +1,3 @@
-/*
-	TODO: Convert to astobj2 -- MVB: jpeeler is looking into this.
-*/
 /*
  * Asterisk -- An open source telephony toolkit.
  *
@@ -113,15 +110,14 @@
 	char peername[1024];
 	unsigned char moh_trys;
 	struct ast_parkinglot *parkinglot;
-	AST_LIST_ENTRY(parkeduser) list;	/* Temporary disabled, will come back to an Asterisk near you soon */
+	AST_LIST_ENTRY(parkeduser) list;
 };
 
 AST_LIST_HEAD(parkinglot_parklist, parkeduser);
 
-/*! \brief Structure for parking lots in a linked list. */
+/*! \brief Structure for parking lots which are put in a container. */
 struct ast_parkinglot {
-	//ASTOBJ_COMPONENTS(struct ast_parkinglot);	/*!< various object stuff, including ->name */
-	char name[80];
+	char name[AST_MAX_CONTEXT];
 	char parking_con[AST_MAX_EXTENSION];		/*!< Context for which parking is made accessible */
 	char parking_con_dial[AST_MAX_EXTENSION];	/*!< Context for dialback for parking (KLUDGE) */
 	int parking_start;				/*!< First available extension for parking */
@@ -133,13 +129,7 @@
 	struct parkinglot_parklist parkings;		/*!< List of active parkings in this parkinglot */
 };
 
-/*! \brief The list of parking lots configured. Always at least one  - the default parking lot jpeeler:astobj1*/
-/*
-struct ast_parkinglot_list {
-	ASTOBJ_CONTAINER_COMPONENTS(struct ast_parkinglot);
-} parkinglots;
-*/
-
+/*! \brief The list of parking lots configured. Always at least one  - the default parking lot */
 static struct ao2_container *parkinglots;
  
 struct ast_parkinglot *default_parkinglot;
@@ -197,17 +187,15 @@
 static struct ast_app *stopmixmonitor_app = NULL;
 static int stopmixmonitor_ok = 1;
 
-
+static pthread_t parking_thread;
 
 /* Forward declarations */
 static struct ast_parkinglot *parkinglot_addref(struct ast_parkinglot *parkinglot);
 static void parkinglot_unref(struct ast_parkinglot *parkinglot);
 static void parkinglot_destroy(void *obj);
 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);
 
-static pthread_t parking_thread;
 
 const char *ast_parking_ext(void)
 {
@@ -468,7 +456,6 @@
 		return -1;
 	}
 
-	//ASTOBJ_WRLOCK(parkinglot);
 	ao2_lock(parkinglot);
 
 	/* Lock parking list */
@@ -481,7 +468,6 @@
 			parkinglot_unref(parkinglot);
 			ast_free(pu);
 			ast_log(LOG_WARNING, "Requested parking extension already exists: %s@%s\n", parkingexten, parkinglot->parking_con);
-			//ASTOBJ_UNLOCK(parkinglot);
 			ao2_unlock(parkinglot);
 			return 1;	/* Continue execution if possible */
 		}
@@ -505,7 +491,6 @@
 			ast_free(pu);
 			AST_LIST_UNLOCK(&parkinglot->parkings);
 			parkinglot_unref(parkinglot);
-			//ASTOBJ_UNLOCK(parkinglot);
 			ao2_unlock(parkinglot);
 			return -1;
 		}
@@ -547,9 +532,8 @@
 	if (peer == chan) 
 		pu->notquiteyet = 1;
 	AST_LIST_UNLOCK(&parkinglot->parkings);
-
-	//ASTOBJ_UNLOCK(parkinglot)
 	ao2_unlock(parkinglot);
+
 	/* Wake up the (presumably select()ing) thread */
 	pthread_kill(parking_thread, SIGURG);
 	ast_verb(2, "Parked %s on %d (lot %s). Will timeout back to extension [%s] %s, %d in %d seconds\n", pu->chan->name, pu->parkingnum, parkinglot->name, pu->context, pu->exten, pu->priority, (pu->parkingtime/1000));
@@ -2268,7 +2252,6 @@
 
 	/* jpeeler: this either needs to be moved or is not necessary: */
 	/*parkinglot_addref(curlot);*/
-	//ASTOBJ_WRLOCK(curlot);
 	ao2_lock(curlot);
 	/* Lock parking list */
 	AST_LIST_LOCK(&curlot->parkings);
@@ -2420,8 +2403,6 @@
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
 	AST_LIST_UNLOCK(&curlot->parkings);
-
-	//ASTOBJ_UNLOCK(curlot);
 	ao2_unlock(curlot);
 	return res;
 }
@@ -2445,13 +2426,6 @@
 		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, &ms, &max);
-			ASTOBJ_UNLOCK(iterator);
-		} while (0) );
-		*/
 		struct ao2_iterator iter;
 		struct ast_parkinglot *curlot;
 		iter = ao2_iterator_init(parkinglots, 0);
@@ -2484,7 +2458,6 @@
 
 	ast_copy_string(tmp_parkinglot.name, name, sizeof(tmp_parkinglot.name));
 
-	//parkinglot = ASTOBJ_CONTAINER_FIND(&parkinglots, name);
 	parkinglot = ao2_find(parkinglots, &tmp_parkinglot, OBJ_POINTER);
 
 	if (parkinglot && option_debug)
@@ -2685,23 +2658,16 @@
 	then go ahead and delete it */
 static void parkinglot_unref(struct ast_parkinglot *parkinglot) 
 {
-	/*
+	int refcount = ao2_ref(parkinglot, -1);
 	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "Multiparking: %s refcount now %d\n", parkinglot->name, parkinglot->refcount - 1);
-	*/
-	//ASTOBJ_UNREF(parkinglot, parkinglot_destroy);
-	ao2_ref(parkinglot, -1);
+		ast_log(LOG_DEBUG, "Multiparking: %s refcount now %d\n", parkinglot->name, refcount - 1);
 }
 
 static struct ast_parkinglot *parkinglot_addref(struct ast_parkinglot *parkinglot)
 {
-	// doesn't look like astobj2 makes the refcount accessible
-	/*
+	int refcount = ao2_ref(parkinglot, +1);
 	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "Multiparking: %s refcount now %d\n", parkinglot->name, parkinglot->refcount + 1);
-	*/
-	//return ASTOBJ_REF(parkinglot);
-	ao2_ref(parkinglot, +1);
+		ast_log(LOG_DEBUG, "Multiparking: %s refcount now %d\n", parkinglot->name, refcount + 1);
 	return parkinglot;
 }
 
@@ -2713,12 +2679,9 @@
 	if (!name)
 		return NULL;
 
-	//newlot = ast_calloc(1, sizeof(*newlot));
 	newlot = ao2_alloc(sizeof(*newlot), parkinglot_destroy);
 	if (!newlot)
 		return NULL;
-
-	//ASTOBJ_INIT(newlot);
 	
 	ast_copy_string(newlot->name, name, sizeof(newlot->name));
 
@@ -2733,9 +2696,7 @@
 	con = ast_context_find(ruin->parking_con);
 	if (con)
 		ast_context_destroy(con, registrar);
-	//ASTOBJ_CONTAINER_UNLINK(&parkinglots, ruin);	/* Remove from parkinglot list */
 	ao2_unlink(parkinglots, ruin);
-	//free(ruin);
 }
 
 /*! \brief Build parkinglot from configuration and chain it in */
@@ -2749,7 +2710,7 @@
 	int start = 0, end = 0;
 
 	parkinglot = find_parkinglot(name);
-	/*
+	/* TODO: confirm astobj2 doesn't have marking
 	if (parkinglot)
 		ASTOBJ_UNMARK(parkinglot);
 	else
@@ -2761,7 +2722,6 @@
 	if (!parkinglot)
 		return NULL;
 
-	//ASTOBJ_WRLOCK(parkinglot);
 	ao2_lock(parkinglot);
 
 	if (option_debug)
@@ -2817,7 +2777,6 @@
 	if (ast_add_extension2(con, 1, ast_parking_ext(), 1, NULL, NULL, parkcall, strdup(""), ast_free, registrar) == -1)
 		error = 1;
 
-	//ASTOBJ_UNLOCK(parkinglot);
 	ao2_unlock(parkinglot);
 
 	if (error) {
@@ -2830,7 +2789,6 @@
 
 
 	/* Move it into the list */
-	//ASTOBJ_CONTAINER_LINK(&parkinglots, parkinglot);
 	ao2_link(parkinglots, parkinglot);
 	parkinglot_unref(parkinglot);
 
@@ -2884,14 +2842,12 @@
 	} else {
 		default_parkinglot = build_parkinglot(DEFAULT_PARKINGLOT, NULL);
 		if (default_parkinglot) {
-			//ASTOBJ_WRLOCK(default_parkinglot);
 			ao2_lock(default_parkinglot);
 			default_parkinglot->parking_start = 701;
 			default_parkinglot->parking_stop = 750;
 			default_parkinglot->parking_offset = 0;
 			default_parkinglot->parkfindnext = 0;
 			default_parkinglot->parkingtime = 0;
-			//ASTOBJ_UNLOCK(default_parkinglot);
 			ao2_unlock(default_parkinglot);
 		}
 	}
@@ -3225,19 +3181,7 @@
 		AST_LIST_UNLOCK(&feature_list);
 	}
 
-	// loop throug all the parking lots
-	/*
-	ASTOBJ_CONTAINER_TRAVERSE(&parkinglots, 1, do {
-		ASTOBJ_RDLOCK(iterator);
-		ast_cli(a->fd, "\nCall parking (Parking lot: %s)\n", iterator->name);
-		ast_cli(a->fd, "------------\n");
-		ast_cli(a->fd,"%-22s:      %s\n", "Parking extension", parking_ext);
-		ast_cli(a->fd,"%-22s:      %s\n", "Parking context", iterator->parking_con);
-		ast_cli(a->fd,"%-22s:      %d-%d\n", "Parked call extensions", iterator->parking_start, iterator->parking_stop);
-		ast_cli(a->fd,"\n");
-		ASTOBJ_UNLOCK(iterator);
-	} while (0) );
-	*/
+	// loop through all the parking lots
 	iter = ao2_iterator_init(parkinglots, 0);
 
 	while ((curlot = ao2_iterator_next(&iter))) {




More information about the asterisk-commits mailing list