[asterisk-commits] russell: trunk r82868 - in /trunk: ./ main/manager.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 18 15:59:21 CDT 2007


Author: russell
Date: Tue Sep 18 15:59:21 2007
New Revision: 82868

URL: http://svn.digium.com/view/asterisk?view=rev&rev=82868
Log:
Merged revisions 82867 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r82867 | russell | 2007-09-18 15:56:43 -0500 (Tue, 18 Sep 2007) | 10 lines

Fix a memory leak that can occur on systems under higher load.  The issue is
that when events are appended to the master event queue, they use the number
of active sessions as a use count so it will know when all active sessions
at the time the event happened have consumed it.  However, the handling of
the number of sessions was not properly synchronized, so the use count was
not always correct, causing an event to disappear early, or get stuck in
the event queue for forever.

(closes issue #9238, reported by bweschke, patch from Ivan, modified by me)

........

Modified:
    trunk/   (props changed)
    trunk/main/manager.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?view=diff&rev=82868&r1=82867&r2=82868
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Tue Sep 18 15:59:21 2007
@@ -749,9 +749,9 @@
 {
 	AST_LIST_LOCK(&sessions);
 	AST_LIST_REMOVE(&sessions, s, list);
+	ast_atomic_fetchadd_int(&num_sessions, -1);
 	AST_LIST_UNLOCK(&sessions);
 
-	ast_atomic_fetchadd_int(&num_sessions, -1);
 	free_session(s);
 }
 
@@ -2527,9 +2527,9 @@
 	s->f = ser->f;
 	s->sin = ser->requestor;
 
-	ast_atomic_fetchadd_int(&num_sessions, 1);
 	AST_LIST_LOCK(&sessions);
 	AST_LIST_INSERT_HEAD(&sessions, s, list);
+	ast_atomic_fetchadd_int(&num_sessions, 1);
 	AST_LIST_UNLOCK(&sessions);
 	/* Hook to the tail of the event queue */
 	s->last_ev = grab_last();
@@ -3076,8 +3076,8 @@
 		s->last_ev = grab_last();
 		AST_LIST_LOCK(&sessions);
 		AST_LIST_INSERT_HEAD(&sessions, s, list);
+		ast_atomic_fetchadd_int(&num_sessions, 1);
 		AST_LIST_UNLOCK(&sessions);
-		ast_atomic_fetchadd_int(&num_sessions, 1);
 	}
 
 	ast_mutex_unlock(&s->__lock);




More information about the asterisk-commits mailing list