[asterisk-commits] mmichelson: branch mmichelson/queue_refcount r81229 - /team/mmichelson/queue_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 28 11:09:33 CDT 2007


Author: mmichelson
Date: Tue Aug 28 11:09:33 2007
New Revision: 81229

URL: http://svn.digium.com/view/asterisk?view=rev&rev=81229
Log:
Made some improvements to the reference counting. I now have run some more tests and tweaked the reference counting.
I ran tests where I knew queues should be destroyed, both with calls and without calls. Things appear to be working properly
at least with static queues. As far as realtime goes, that'll require some more setup.

One nice thing, it appears that I've cleared up a possible memory leak that was present before, and reference counting is nice
since we don't have to check the queue's count to see if we can destroy it...it just works!


Modified:
    team/mmichelson/queue_refcount/apps/app_queue.c

Modified: team/mmichelson/queue_refcount/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue_refcount/apps/app_queue.c?view=diff&rev=81229&r1=81228&r2=81229
==============================================================================
--- team/mmichelson/queue_refcount/apps/app_queue.c (original)
+++ team/mmichelson/queue_refcount/apps/app_queue.c Tue Aug 28 11:09:33 2007
@@ -1003,6 +1003,7 @@
 static void destroy_queue(void *obj)
 {
 	struct call_queue *q = obj;
+	ast_log(LOG_DEBUG, "Queue destructor called for queue '%s'!\n", q->name);
 	free_members(q, 1);
 	ast_mutex_destroy(&q->lock);
 }
@@ -1514,11 +1515,11 @@
 	}
 	ast_mutex_unlock(&q->lock);
 
-	if (q->dead && !q->count) {	
+	if (q->dead) {	
 		/* It's dead and nobody is in it, so kill it */
 		ao2_unlink(queues, q);
-		ao2_ref(q, -1);
-	}
+	}
+	ao2_ref(q, -1);
 }
 
 /* Hang up a list of outgoing calls */
@@ -3930,8 +3931,10 @@
 
 				if (new) {
 					ao2_link(queues, q);
+					ao2_ref(q, 1);
 				} else
 					ast_mutex_unlock(&q->lock);
+				ao2_ref(q, -1);
 			}
 		}
 	}
@@ -3940,11 +3943,6 @@
 	while ((q = ao2_iterator_next(&i))) {
 		if (q->dead) {
 			ao2_unlink(queues, q);
-			if (!q->count) {
-				ao2_ref(q, -1);
-			}
-			else
-				ast_log(LOG_DEBUG, "XXX Leaking a little memory :( XXX\n");
 		} else {
 			ast_mutex_lock(&q->lock);
 			for (cur = q->members; cur; cur = cur->next) {




More information about the asterisk-commits mailing list