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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 2 05:19:20 CDT 2011


Author: irroot
Date: Wed Nov  2 05:19:16 2011
New Revision: 342985

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=342985
Log:
Some doxygen love and rearange ao2 funcs in one place

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=342985&r1=342984&r2=342985
==============================================================================
--- team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c (original)
+++ team/irroot/asterisk-trunk-quack-queue/apps/app_queue.c Wed Nov  2 05:19:16 2011
@@ -1294,40 +1294,6 @@
 	return QUEUE_AUTOPAUSE_OFF;
 }
 
-static int queue_hash_cb(const void *obj, const int flags)
-{
-	const struct call_queue *q = obj;
-	const char *name = (flags & OBJ_KEY) ? obj : q->name;
-
-	return ast_str_case_hash(name);
-}
-
-static int queue_cmp_cb(void *obj, void *arg, int flags)
-{
-	struct call_queue *q = obj;
-	const struct call_queue *q2 = arg;
-	const char *name = (flags & OBJ_POINTER) ? q2->name : arg;
-
-	return !strcasecmp(q->name, name) ? CMP_MATCH | CMP_STOP : 0;
-}
-
-static int device_hash_cb(const void *obj, const int flags)
-{
-	const struct mem_state *s = obj;
-	const char *state_interface = (flags & OBJ_KEY) ? obj : s->state_interface;
-
-	return ast_str_case_hash(state_interface);
-}
-
-static int device_cmp_cb(void *obj, void *arg, int flags)
-{
-	struct mem_state *d = obj;
-	const struct mem_state *d2 = arg;
-	const char *iface = (flags & OBJ_POINTER) ? d2->state_interface : arg;
-
-	return !strcasecmp(d->state_interface, iface) ? CMP_MATCH | CMP_STOP : 0;
-}
-
 /*! \brief Set variables of queue */
 static void set_queue_variables(struct call_queue *q, struct ast_channel *chan)
 {
@@ -1707,16 +1673,87 @@
 	ao2_unlock(m);
 }
 
+/*!
+ * \brief helper function used in creating the hash
+ */
 static int compress_char(const char c)
 {
-	if (c < 32)
+	if (c < 32) {
 		return 0;
-	else if (c > 96)
+	} else if (c > 96) {
 		return c - 64;
-	else
+	} else {
 		return c - 32;
-}
-
+	}
+}
+
+/*!
+ * \brief ao2 callback to calculate hash of a queue by name
+ */
+static int queue_hash_cb(const void *obj, const int flags)
+{
+	const struct call_queue *q = obj;
+	const char *name = (flags & OBJ_KEY) ? obj : q->name;
+
+	return ast_str_case_hash(name);
+}
+
+
+/*!
+ * \brief ao2 callback to find queue by name
+ * \note this is the default function used by ao2_find
+ */
+static int queue_cmp_cb(void *obj, void *arg, int flags)
+{
+	struct call_queue *q = obj;
+	const struct call_queue *q2 = arg;
+	const char *name = (flags & OBJ_POINTER) ? q2->name : arg;
+
+	return !strcasecmp(q->name, name) ? CMP_MATCH | CMP_STOP : 0;
+}
+
+/*!
+ * \brief ao2 callback to mark static queues dead
+ */
+static int mark_queues_dead(void *obj, void *arg, int flags)
+{
+	struct call_queue *q = obj;
+	const struct call_queue *q2 = arg;
+	const char *queuename = (flags & OBJ_POINTER) ? q2->name : arg;
+
+	ao2_lock(q);
+	if (!q->realtime && (ast_strlen_zero(queuename) || !strcasecmp(queuename, q->name))) {
+		q->dead = 1;
+		ao2_unlock(q);
+		return CMP_MATCH;
+	}
+	ao2_unlock(q);
+
+	return 0;
+}
+
+/*!
+ * \brief ao2 callback to delete queues marked dead
+ */
+static int kill_dead_queues(void *obj, void *arg, int flags)
+{
+	struct call_queue *q = obj;
+	const struct call_queue *q2 = arg;
+	const char *queuename = (flags & OBJ_POINTER) ? q2->name : arg;
+
+	ao2_lock(q);
+	if ((ast_strlen_zero(queuename) || !strcasecmp(queuename, q->name)) && q->dead) {
+		ao2_unlock(q);
+		return CMP_MATCH;
+	}
+	ao2_unlock(q);
+
+	return 0;
+}
+
+/*!
+ * \brief ao2 callback to calculate hash of a member by interface
+ */
 static int member_hash_fn(const void *obj, const int flags)
 {
 	const struct member *mem = obj;
@@ -1733,6 +1770,10 @@
 	return ret;
 }
 
+/*!
+ * \brief ao2 callback to find member by interface
+ * \note this is the default function used by ao2_find
+ */
 static int member_cmp_fn(void *obj1, void *obj2, int flags)
 {
 	struct member *mem1 = obj1;
@@ -1742,6 +1783,9 @@
 	return strcasecmp(mem1->interface, arg) ? 0 : CMP_MATCH | CMP_STOP;
 }
 
+/*!
+ * \brief ao2 callback to find a realtime member by uniqueid
+ */
 static int member_cmp_uniqueid_fn(void *obj1, void *arg, int flags)
 {
 	struct member *mem1 = obj1;
@@ -1759,9 +1803,65 @@
 }
 
 /*!
+ * \brief ao2 callback to mark static members dead
+ */
+static int mark_static_member_dead(void *obj, void *arg, int flags)
+{
+	struct member *member = obj;
+	ao2_lock(member);
+	if (!(member->dynamic | member->realtime)) {
+		member->dead = 1;
+		ao2_unlock(member);
+		return CMP_MATCH;
+	}
+	ao2_unlock(member);
+	return 0;
+}
+
+/*!
+ * \brief ao2 callback to delete static members marked dead
+ */
+static int kill_static_dead_members(void *obj, void *arg, int flags)
+{
+	struct member *member = obj;
+
+	ao2_lock(member);
+	if (!(member->dynamic | member->realtime) && member->dead) {
+		ao2_unlock(member);
+		return CMP_MATCH;
+	}
+	ao2_unlock(member);
+	return 0;
+}
+
+/*!
+ * \brief ao2 callback to calculate hash of a device by state_interface
+ */
+static int device_hash_cb(const void *obj, const int flags)
+{
+	const struct mem_state *s = obj;
+	const char *state_interface = (flags & OBJ_KEY) ? obj : s->state_interface;
+
+	return ast_str_case_hash(state_interface);
+}
+
+/*!
+ * \brief ao2 callback to find device by state_interface
+ * \note this is the default function used by ao2_find
+ */
+static int device_cmp_cb(void *obj, void *arg, int flags)
+{
+	struct mem_state *d = obj;
+	const struct mem_state *d2 = arg;
+	const char *iface = (flags & OBJ_POINTER) ? d2->state_interface : arg;
+
+	return !strcasecmp(d->state_interface, iface) ? CMP_MATCH | CMP_STOP : 0;
+}
+
+/*!
  * \brief Initialize Queue default values.
  * \note the queue's lock  must be held before executing this function
-*/
+ */
 static void init_queue(struct call_queue *q)
 {
 	int i;
@@ -7037,31 +7137,6 @@
 	return mcat;
 }
 
-static int mark_member_dead(void *obj, void *arg, int flags)
-{
-	struct member *member = obj;
-	ao2_lock(member);
-	if (!(member->dynamic | member->realtime)) {
-		member->dead = 1;
-		ao2_unlock(member);
-	}
-	ao2_unlock(member);
-	return 0;
-}
-
-static int kill_dead_members(void *obj, void *arg, int flags)
-{
-	struct member *member = obj;
-
-	ao2_lock(member);
-	if ((!(member->dynamic | member->realtime)) && member->dead) {
-		ao2_unlock(member);
-		return CMP_MATCH;
-	}
-	ao2_unlock(member);
-	return 0;
-}
-
 /*! \brief Reload information pertaining to a particular queue
  *
  * Once we have isolated a queue within reload_queues, we call this. This will either
@@ -7139,11 +7214,12 @@
 	}
 
 	if (mcfg) {
-		ao2_callback(q->members, OBJ_NODATA, mark_member_dead, NULL);
+		ao2_callback(q->members, OBJ_NODATA | OBJ_MULTIPLE, mark_static_member_dead, NULL);
 		while ((interface = ast_category_browse(mcfg, interface))) {
 			handle_member_record(q, interface, mcfg, MEMBER_STATIC, "queues.conf");
 		}
-		ast_config_destroy(mcfg);
+		/* Free remaining members marked as dead */
+		ao2_callback(q->members, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, kill_static_dead_members, q);
 
 		/* load the realtime agents*/
 		rt_load_member_config(q);
@@ -7153,43 +7229,9 @@
 			pm_load_member_config(q);
 		}
 
-		/* Free remaining members marked as dead */
-		ao2_callback(q->members, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, kill_dead_members, q);
+		ast_config_destroy(mcfg);
 	}
 	ao2_t_ref(q, -1, "Expiring creation reference");
-}
-
-static int mark_queues_dead(void *obj, void *arg, int flags)
-{
-	struct call_queue *q = obj;
-	const struct call_queue *q2 = arg;
-	const char *queuename = (flags & OBJ_POINTER) ? q2->name : arg;
-
-	ao2_lock(q);
-	if (!q->realtime && (ast_strlen_zero(queuename) || !strcasecmp(queuename, q->name))) {
-		q->dead = 1;
-		ao2_unlock(q);
-		return CMP_MATCH;
-	}
-	ao2_unlock(q);
-
-	return 0;
-}
-
-static int kill_dead_queues(void *obj, void *arg, int flags)
-{
-	struct call_queue *q = obj;
-	const struct call_queue *q2 = arg;
-	const char *queuename = (flags & OBJ_POINTER) ? q2->name : arg;
-
-	ao2_lock(q);
-	if ((ast_strlen_zero(queuename) || !strcasecmp(queuename, q->name)) && q->dead) {
-		ao2_unlock(q);
-		return CMP_MATCH;
-	}
-	ao2_unlock(q);
-
-	return 0;
 }
 
 /*! \brief reload the queues.conf file




More information about the asterisk-commits mailing list