[asterisk-commits] irroot: branch irroot/asterisk-trunk-quack-queue r342982 - /team/irroot/aster...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 2 00:45:40 CDT 2011


Author: irroot
Date: Wed Nov  2 00:45:37 2011
New Revision: 342982

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=342982
Log:
Removed defines for internal ao2 funcs they were not used consistantly.


Modified:
    team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c

Modified: team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c?view=diff&rev=342982&r1=342981&r2=342982
==============================================================================
--- team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c (original)
+++ team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c Wed Nov  2 00:45:37 2011
@@ -99,9 +99,6 @@
 #include "asterisk/callerid.h"
 #include "asterisk/cel.h"
 #include "asterisk/data.h"
-
-/* Define, to debug reference counts on queues, without debugging reference counts on queue members */
-/* #define REF_DEBUG_ONLY_QUEUES */
 
 /*!
  * \par Please read before modifying this file.
@@ -1331,31 +1328,6 @@
 	return !strcasecmp(d->state_interface, iface) ? CMP_MATCH | CMP_STOP : 0;
 }
 
-#ifdef REF_DEBUG_ONLY_QUEUES
-#define queue_ref(a)	__ao2_ref_debug(a,1,"",__FILE__,__LINE__,__PRETTY_FUNCTION__)
-#define queue_unref(a)	__ao2_ref_debug(a,-1,"",__FILE__,__LINE__,__PRETTY_FUNCTION__)
-#define queue_t_ref(a,b)	__ao2_ref_debug(a,1,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
-#define queue_t_unref(a,b)	__ao2_ref_debug(a,-1,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
-#define queues_t_link(c,q,tag)	__ao2_link_debug(c,q,tag,__FILE__,__LINE__,__PRETTY_FUNCTION__)
-#define queues_t_unlink(c,q,tag)	__ao2_unlink_debug(c,q,tag,__FILE__,__LINE__,__PRETTY_FUNCTION__)
-#else
-#define queue_t_ref(a,b)	queue_ref(a)
-#define queue_t_unref(a,b)	queue_unref(a)
-#define queues_t_link(c,q,tag)	ao2_t_link(c,q,tag)
-#define queues_t_unlink(c,q,tag)	ao2_t_unlink(c,q,tag)
-static inline struct call_queue *queue_ref(struct call_queue *q)
-{
-        ao2_ref(q, 1);
-        return q;
-}
-
-static inline struct call_queue *queue_unref(struct call_queue *q)
-{
-        ao2_ref(q, -1);
-        return NULL;
-}
-#endif
-
 /*! \brief Set variables of queue */
 static void set_queue_variables(struct call_queue *q, struct ast_channel *chan)
 {
@@ -1400,7 +1372,7 @@
 	/* every queue_ent must have a reference to it's parent call_queue, this
 	 * reference does not go away until the end of the queue_ent's life, meaning
 	 * that even when the queue_ent leaves the call_queue this ref must remain. */
-	queue_ref(q);
+	ao2_ref(q, 1);
 	new->parent = q;
 	new->pos = ++(*pos);
 	new->opos = *pos;
@@ -2439,7 +2411,7 @@
 
 	if ((q = ao2_t_alloc(sizeof(*q), destroy_queue, "Allocate queue"))) {
 		if (ast_string_field_init(q, 64)) {
-			queue_t_unref(q, "String field allocation failed");
+			ao2_t_ref(q, -1, "String field allocation failed");
 			return NULL;
 		}
 		ast_string_field_set(q, name, queuename);
@@ -2546,8 +2518,8 @@
 			   found condition... So we might delete an in-core queue
 			   in case of DB failure. */
 			ast_debug(1, "Queue %s not found in realtime.\n", queuename);
-			queues_t_unlink(queues, q, "Unused; removing from container");
-			queue_t_unref(q, "Queue is dead; can't return it");
+			ao2_t_unlink(queues, q, "Unused; removing from container");
+			ao2_t_ref(q, -1, "Queue is dead; can't return it");
 		}
 		return NULL;
 	}
@@ -2641,7 +2613,7 @@
 				!ast_strlen_zero(queuename);
 				queuename = ast_category_browse(cfg, queuename)) {
 			if ((queue = load_realtime_queue(queuename, rmask))) {
-				queue_unref(queue);
+				ao2_ref(queue, -1);
 			}
 		}
 		ast_config_destroy(cfg);
@@ -2666,7 +2638,7 @@
 	    (get_member_status(q, qe->max_penalty, qe->min_penalty, q->joinempty))) {
 		*reason = QUEUE_JOINEMPTY;
 		ao2_unlock(q);
-		queue_t_unref(q, "Done with realtime queue");
+		ao2_t_ref(q, -1, "Done with realtime queue");
 		return res;
 	}
 	if (*reason == QUEUE_UNKNOWN && q->maxlen && (q->count >= q->maxlen)) {
@@ -2728,7 +2700,7 @@
 		ast_debug(1, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, qe->chan->name, qe->pos );
 	}
 	ao2_unlock(q);
-	queue_t_unref(q, "Done with realtime queue");
+	ao2_t_ref(q, -1, "Done with realtime queue");
 
 	return res;
 }
@@ -2987,7 +2959,7 @@
 	if (!(q = qe->parent)) {
 		return;
 	}
-	queue_t_ref(q, "Copy queue pointer from queue entry");
+	ao2_t_ref(q, 1, "Copy queue pointer from queue entry");
 	ao2_lock(q);
 
 	prev = NULL;
@@ -3018,7 +2990,7 @@
 		}
 	}
 	ao2_unlock(q);
-	queue_t_unref(q, "Expire copied reference");
+	ao2_t_ref(q, -1, "Expire copied reference");
 }
 
 /*!
@@ -3153,7 +3125,7 @@
 	queue_iter = ao2_iterator_init(queues, 0);
 	while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) {
 		if (q == rq) { /* don't check myself, could deadlock */
-			queue_t_unref(q, "Done with iterator");
+			ao2_t_ref(q, -1, "Done with iterator");
 			continue;
 		}
 
@@ -4332,7 +4304,7 @@
 				ao2_ref(mem, -1);
 				ao2_unlock(mem);
 			}
-			queue_t_unref(qtmp, "Done with iterator");
+			ao2_t_ref(qtmp, -1, "Done with iterator");
 		}
 		ao2_iterator_destroy(&queue_iter);
 	} else {
@@ -4605,7 +4577,7 @@
 	if (ao2_ref(qeb, -1) == 1) {
 		set_queue_variables(q, chan);
 		/* This unrefs the reference we made in try_calling when we allocated qeb */
-		queue_t_unref(q, "Expire bridge_config reference");
+		ao2_t_ref(q, -1, "Expire bridge_config reference");
 	}
 }
 
@@ -5421,7 +5393,7 @@
 			 * to make sure to increase the refcount of this queue so it cannot be freed until we
 			 * are done with it. We remove this reference in end_bridge_callback.
 			 */
-			queue_t_ref(qe->parent, "For bridge_config reference");
+			ao2_t_ref(qe->parent, 1, "For bridge_config reference");
 		}
 
 		time(&callstart);
@@ -5724,7 +5696,7 @@
 			ao2_unlock(mem);
 			ao2_ref(mem, -1);
 		}
-		queue_t_unref(q, "Done with iterator");
+		ao2_t_ref(q, -1, "Done with iterator");
 	}
 	ao2_iterator_destroy(&queue_iter);
 
@@ -6418,7 +6390,8 @@
 		/* every queue_ent is given a reference to it's parent call_queue when it joins the queue.
 		 * This ref must be taken away right before the queue_ent is destroyed.  In this case
 		 * the queue_ent is about to be returned on the stack */
-		qe.parent = queue_unref(qe.parent);
+		ao2_ref(qe.parent, -1);
+		qe.parent = NULL;
 	}
 
 	return res;
@@ -6460,7 +6433,7 @@
 		}
 
 		ao2_unlock(q);
-		queue_t_unref(q, "Done with QUEUE() function");
+		ao2_t_ref(q, -1, "Done with QUEUE() function");
 	} else {
 		ast_log(LOG_WARNING, "queue %s was not found\n", data);
 	}
@@ -6487,7 +6460,7 @@
 	q = load_realtime_queue(data, 0);
 	snprintf(buf, len, "%d", q != NULL? 1 : 0);
 	if (q) {
-		queue_t_unref(q, "Done with temporary reference in QUEUE_EXISTS()");
+		ao2_t_ref(q, -1, "Done with temporary reference in QUEUE_EXISTS()");
 	}
 
 	return 0;
@@ -6586,7 +6559,7 @@
 			ao2_unlock(m);
 			ao2_ref(m, -1);
 		}
-		queue_t_unref(q, "Done with temporary reference in QUEUE_MEMBER()");
+		ao2_t_ref(q, -1, "Done with temporary reference in QUEUE_MEMBER()");
 	} else {
 		ast_log(LOG_WARNING, "queue %s was not found\n", args.queuename);
 	}
@@ -6718,7 +6691,7 @@
 			ao2_ref(m, -1);
 		}
 		ao2_iterator_destroy(&mem_iter);
-		queue_t_unref(q, "Done with temporary reference in QUEUE_MEMBER_COUNT");
+		ao2_t_ref(q, -1, "Done with temporary reference in QUEUE_MEMBER_COUNT");
 	} else {
 		ast_log(LOG_WARNING, "queue %s was not found\n", data);
 	}
@@ -6746,7 +6719,7 @@
 		ao2_lock(q);
 		count = q->count;
 		ao2_unlock(q);
-		queue_t_unref(q, "Done with reference in QUEUE_WAITING_COUNT()");
+		ao2_t_ref(q, -1, "Done with reference in QUEUE_WAITING_COUNT()");
 	} else if ((var = ast_load_realtime("queues", "name", data, SENTINEL))) {
 		/* if the queue is realtime but was not found in memory, this
 		 * means that the queue had been deleted from memory since it was
@@ -6804,7 +6777,7 @@
 		ao2_ref(m, -1);
 	}
 	ao2_iterator_destroy(&mem_iter);
-	queue_t_unref(q, "Done with QUEUE_MEMBER_LIST()");
+	ao2_t_ref(q, -1, "Done with QUEUE_MEMBER_LIST()");
 
 	/* We should already be terminated, but let's make sure. */
 	buf[len - 1] = '\0';
@@ -7184,7 +7157,7 @@
 		/* Free remaining members marked as dead */
 		ao2_callback(q->members, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, kill_dead_members, q);
 	}
-	queue_t_unref(q, "Expiring creation reference");
+	ao2_t_ref(q, -1, "Expiring creation reference");
 }
 
 static int mark_queues_dead(void *obj, void *arg, int flags)
@@ -7298,7 +7271,7 @@
 		if (ast_strlen_zero(queuename) || !strcasecmp(q->name, queuename))
 			clear_queue(q);
 		ao2_unlock(q);
-		queue_t_unref(q, "Done with iterator");
+		ao2_t_ref(q, -1, "Done with iterator");
 	}
 	ao2_iterator_destroy(&queue_iter);
 	return 0;
@@ -7373,7 +7346,7 @@
 		float sl;
 
 		if (argc == 3 && strcasecmp(q->name, argv[2])) {
-			queue_t_unref(q, "Done with iterator");
+			ao2_t_ref(q, -1, "Done with iterator");
 			continue;
 		}
 		found = 1;
@@ -7451,7 +7424,7 @@
 		}
 		do_print(s, fd, "");	/* blank line between entries */
 		ao2_unlock(q);
-		queue_t_unref(q, "Done with iterator"); /* Unref the iterator's reference */
+		ao2_t_ref(q, -1, "Done with iterator"); /* Unref the iterator's reference */
 	}
 	ao2_iterator_destroy(&queue_iter);
 
@@ -7478,10 +7451,10 @@
 	while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) {
 		if (!strncasecmp(word, q->name, wordlen) && ++which > state) {
 			ret = ast_strdup(q->name);
-			queue_t_unref(q, "Done with iterator");
+			ao2_t_ref(q, -1, "Done with iterator");
 			break;
 		}
-		queue_t_unref(q, "Done with iterator");
+		ao2_t_ref(q, -1, "Done with iterator");
 	}
 	ao2_iterator_destroy(&queue_iter);
 
@@ -7633,7 +7606,7 @@
 			"\r\n",
 			q->name, qmemcount, qmemavail, qchancount, q->holdtime, q->talktime, qlongestholdtime, idText);
 		ao2_unlock(q);
-		queue_t_unref(q, "Done with iterator");
+		ao2_t_ref(q, -1, "Done with iterator");
 	}
 	ao2_iterator_destroy(&queue_iter);
 	astman_append(s,
@@ -7748,7 +7721,7 @@
 				(long) (now - qe->start), idText);
 		}
 		ao2_unlock(q);
-		queue_t_unref(q, "Done with iterator");
+		ao2_t_ref(q, -1, "Done with iterator");
 	}
 	ao2_iterator_destroy(&queue_iter);
 
@@ -8179,7 +8152,7 @@
 				ao2_unlock(m);
 				tmp = ast_strdup(m->interface);
 				ao2_ref(m, -1);
-				queue_t_unref(q, "Done with iterator, returning interface name");
+				ao2_t_ref(q, -1, "Done with iterator, returning interface name");
 				ao2_iterator_destroy(&mem_iter);
 				ao2_iterator_destroy(&queue_iter);
 				return tmp;
@@ -8188,7 +8161,7 @@
 			ao2_ref(m, -1);
 		}
 		ao2_iterator_destroy(&mem_iter);
-		queue_t_unref(q, "Done with iterator");
+		ao2_t_ref(q, -1, "Done with iterator");
 	}
 	ao2_iterator_destroy(&queue_iter);
 
@@ -8851,7 +8824,7 @@
 	i = ao2_iterator_init(queues, 0);
 	while ((queue = ao2_iterator_next(&i))) {
 		queues_data_provider_get_helper(search, data_root, queue);
-		queue_unref(queue);
+		ao2_ref(queue, -1);
 	}
 	ao2_iterator_destroy(&i);
 
@@ -8915,8 +8888,8 @@
 
 	q_iter = ao2_iterator_init(queues, 0);
 	while ((q = ao2_t_iterator_next(&q_iter, "Iterate through queues"))) {
-		queues_t_unlink(queues, q, "Remove queue from container due to unload");
-		queue_t_unref(q, "Done with iterator");
+		ao2_t_unlink(queues, q, "Done with iterator");
+		ao2_t_ref(q, -1, "Done with iterator");
 	}
 	ao2_iterator_destroy(&q_iter);
 	ao2_ref(queues, -1);




More information about the asterisk-commits mailing list