[asterisk-commits] bweschke: branch bweschke/eventq-sanity-checks r58892 - /team/bweschke/eventq...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Mar 14 05:36:55 MST 2007


Author: bweschke
Date: Wed Mar 14 07:36:55 2007
New Revision: 58892

URL: http://svn.digium.com/view/asterisk?view=rev&rev=58892
Log:
 Hopefully this is the fix we need to fix what needs to be fixed.


Modified:
    team/bweschke/eventq-sanity-checks/main/manager.c

Modified: team/bweschke/eventq-sanity-checks/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/eventq-sanity-checks/main/manager.c?view=diff&rev=58892&r1=58891&r2=58892
==============================================================================
--- team/bweschke/eventq-sanity-checks/main/manager.c (original)
+++ team/bweschke/eventq-sanity-checks/main/manager.c Wed Mar 14 07:36:55 2007
@@ -2211,20 +2211,18 @@
 		AST_LIST_TRAVERSE_SAFE_END
 		/* Go through the list of events and prepare any older than max age 
 		   for purge */
-		/* prev = master_eventq;
-		while (prev->next) {
-			prev = prev->next;
-			if (prev->timeposted < (now - maxeventage)) 
-				while (!ast_atomic_dec_and_test(&prev->usecount));
-		} */
 		/* Purge master event queue of old, unused events, but make sure we
 		   always keep at least one in the queue */
-		eqe = master_eventq;
-		while (master_eventq->next && !master_eventq->usecount) {
-			eqe = master_eventq;
-			master_eventq = master_eventq->next;
+		prev = master_eventq;
+		while (prev->next && (!prev->usecount || prev->timeposted < (now - maxeventage))) {
+			eqe = prev;
+			prev = prev->next;
 			free(eqe);
 		}
+		if (!prev->usecount)
+			ast_atomic_fetchadd_int(&prev->usecount, 1);
+		master_eventq = prev;
+
 		if (option_debug > 2) 
 			ast_log(LOG_DEBUG, "Num sessions after cleanup: %d\n", num_sessions);
 		AST_LIST_UNLOCK(&sessions);



More information about the asterisk-commits mailing list