[asterisk-commits] irroot: branch irroot/distrotech-customers-1.8 r335125 - /team/irroot/distrot...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Sep 10 15:44:05 CDT 2011


Author: irroot
Date: Sat Sep 10 15:44:01 2011
New Revision: 335125

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=335125
Log:
Remove ao2_lock(queues) from app_queue its not required with ao2

Modified:
    team/irroot/distrotech-customers-1.8/apps/app_queue.c

Modified: team/irroot/distrotech-customers-1.8/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/apps/app_queue.c?view=diff&rev=335125&r1=335124&r2=335125
==============================================================================
--- team/irroot/distrotech-customers-1.8/apps/app_queue.c (original)
+++ team/irroot/distrotech-customers-1.8/apps/app_queue.c Sat Sep 10 15:44:01 2011
@@ -2418,13 +2418,11 @@
 			queue_t_unref(q, "Need to find realtime queue");
 		}
 
-		ao2_lock(queues);
-
 		q = find_queue_by_name_rt(queuename, queue_vars, member_config);
 		ast_config_destroy(member_config);
 		ast_variables_destroy(queue_vars);
 
-		/* update the use_weight value if the queue's has gained or lost a weight */ 
+		/* update the use_weight value if the queue's has gained or lost a weight */
 		if (q) {
 			if (!q->weight && prev_weight) {
 				ast_atomic_fetchadd_int(&use_weight, -1);
@@ -2434,8 +2432,6 @@
 			}
 		}
 		/* Other cases will end up with the proper value for use_weight */
-		ao2_unlock(queues);
-
 	} else {
 		update_realtime_members(q);
 	}
@@ -2464,15 +2460,13 @@
 	struct ao2_iterator mem_iter;
 
 	if (!(member_config = ast_load_realtime_multientry("queue_members", "interface LIKE", "%", "queue_name", q->name , SENTINEL))) {
-		/*This queue doesn't have realtime members*/
-		ast_debug(3, "Queue %s has no realtime members defined. No need for update\n", q->name);
+		/*This queue doesn't have realtime members*/		ast_debug(3, "Queue %s has no realtime members defined. No need for update\n", q->name);
 		return;
 	}
 
-	ao2_lock(queues);
 	ao2_lock(q);
-	
-	/* Temporarily set realtime  members dead so we can detect deleted ones.*/ 
+
+	/* Temporarily set realtime  members dead so we can detect deleted ones.*/
 	mem_iter = ao2_iterator_init(q->members, 0);
 	while ((m = ao2_iterator_next(&mem_iter))) {
 		if (m->realtime)
@@ -2501,7 +2495,6 @@
 	}
 	ao2_iterator_destroy(&mem_iter);
 	ao2_unlock(q);
-	ao2_unlock(queues);
 	ast_config_destroy(member_config);
 }
 
@@ -2516,7 +2509,6 @@
 	if (!(q = load_realtime_queue(queuename)))
 		return res;
 
-	ao2_lock(queues);
 	ao2_lock(q);
 
 	/* This is our one */
@@ -2525,7 +2517,6 @@
 		if ((status = get_member_status(q, qe->max_penalty, qe->min_penalty, q->joinempty))) {
 			*reason = QUEUE_JOINEMPTY;
 			ao2_unlock(q);
-			ao2_unlock(queues);
 			queue_t_unref(q, "Done with realtime queue");
 			return res;
 		}
@@ -2589,7 +2580,6 @@
 		ast_debug(1, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, qe->chan->name, qe->pos );
 	}
 	ao2_unlock(q);
-	ao2_unlock(queues);
 	queue_t_unref(q, "Done with realtime queue");
 
 	return res;
@@ -2983,7 +2973,6 @@
 	int found = 0;
 	struct ao2_iterator queue_iter;
 
-	ao2_lock(queues);
 	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 */
@@ -3008,7 +2997,6 @@
 		}
 	}
 	ao2_iterator_destroy(&queue_iter);
-	ao2_unlock(queues);
 	return found;
 }
 
@@ -4106,10 +4094,9 @@
 
 	struct member *mem;
 	struct call_queue *qtmp;
-	struct ao2_iterator queue_iter;
-
+	struct ao2_iterator queue_iter;	
+	
 	if (shared_lastcall) {
-		ao2_lock(queues);
 		queue_iter = ao2_iterator_init(queues, 0);
 		while ((qtmp = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) {
 			ao2_lock(qtmp);
@@ -4123,7 +4110,6 @@
 			queue_t_unref(qtmp, "Done with iterator");
 		}
 		ao2_iterator_destroy(&queue_iter);
-		ao2_unlock(queues);
 	} else {
 		ao2_lock(q);
 		time(&member->lastcall);
@@ -4532,7 +4518,6 @@
 		qe->cancel_answered_elsewhere = 1;
 	}
 
-	/* Hold the lock while we setup the outgoing calls */
 	ao2_lock(qe->parent);
 	ast_debug(1, "%s is trying to call a queue member.\n",
 							qe->chan->name);
@@ -5286,7 +5271,6 @@
 
 	ast_copy_string(tmpmem.interface, interface, sizeof(tmpmem.interface));
 	if ((q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Temporary reference for interface removal"))) {
-		ao2_lock(queues);
 		ao2_lock(q);
 		if ((mem = ao2_find(q->members, &tmpmem, OBJ_POINTER))) {
 			/* XXX future changes should beware of this assumption!! */
@@ -5297,7 +5281,6 @@
 				ao2_ref(mem, -1);
 				ao2_unlock(q);
 				queue_t_unref(q, "Interface wasn't dynamic, expiring temporary reference");
-				ao2_unlock(queues);
 				return RES_NOT_DYNAMIC;
 			}
 			q->membercount--;
@@ -5317,7 +5300,6 @@
 			res = RES_EXISTS;
 		}
 		ao2_unlock(q);
-		ao2_unlock(queues);
 		queue_t_unref(q, "Expiring temporary reference");
 	}
 
@@ -5341,8 +5323,6 @@
 	 * short-circuits if the queue is already in memory. */
 	if (!(q = load_realtime_queue(queuename)))
 		return res;
-
-	ao2_lock(queues);
 
 	ao2_lock(q);
 	if ((old_member = interface_exists(q, interface)) == NULL) {
@@ -5381,7 +5361,6 @@
 		res = RES_EXISTS;
 	}
 	ao2_unlock(q);
-	ao2_unlock(queues);
 	queue_t_unref(q, "Expiring temporary reference");
 
 	return res;
@@ -5561,8 +5540,6 @@
 	struct call_queue *cur_queue;
 	char queue_data[PM_MAX_LEN];
 
-	ao2_lock(queues);
-
 	/* Each key in 'pm_family' is the name of a queue */
 	db_tree = ast_db_gettree(pm_family, NULL);
 	for (entry = db_tree; entry; entry = entry->next) {
@@ -5633,7 +5610,6 @@
 		queue_t_unref(cur_queue, "Expire reload reference");
 	}
 
-	ao2_unlock(queues);
 	if (db_tree) {
 		ast_log(LOG_NOTICE, "Queue members successfully reloaded from database.\n");
 		ast_db_freetree(db_tree);
@@ -7019,9 +6995,6 @@
 		return -1;
 	}
 
-	/* We've made it here, so it looks like we're doing operations on all queues. */
-	ao2_lock(queues);
-	
 	/* Mark all queues as dead for the moment if we're reloading queues.
 	 * For clarity, we could just be reloading members, in which case we don't want to mess
 	 * with the other queue parameters at all*/
@@ -7045,10 +7018,9 @@
 	if (queue_reload) {
 		ao2_callback(queues, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, kill_dead_queues, (char *) queuename);
 	}
-	ao2_unlock(queues);
 	return 0;
 }
-  
+
 /*! \brief Facilitates resetting statistics for a queue
  *
  * This function actually does not reset any statistics, but
@@ -7154,7 +7126,6 @@
 	}
 
 	queue_iter = ao2_iterator_init(queues, AO2_ITERATOR_DONTLOCK);
-	ao2_lock(queues);
 	while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) {
 		float sl;
 		struct call_queue *realtime_queue = NULL;
@@ -7245,7 +7216,6 @@
 		queue_t_unref(q, "Done with iterator"); /* Unref the iterator's reference */
 	}
 	ao2_iterator_destroy(&queue_iter);
-	ao2_unlock(queues);
 	if (!found) {
 		if (argc == 3)
 			ast_str_set(&out, 0, "No such queue: %s.", argv[2]);




More information about the asterisk-commits mailing list