From: Matthew Jordan Date: Sun, 4 Nov 2012 03:08:12 +0000 (+0000) Subject: Don't attempt to purge sessions when no sessions exist X-Git-Tag: 10.11.0-rc1~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9777a24dcfa04860f3cddd5b1388d08f05de6f90;p=thirdparty%2Fasterisk.git Don't attempt to purge sessions when no sessions exist Manager's tcp/tls objects have a periodic function that purge old manager sessions periodically. During shutdown, the underlying container holding those sessions can be disposed of and set to NULL before the tcp/tls periodic function is stopped. If the periodic function fires, it will attempt to iterate over a NULL container. This patch checks for whether or not the sessions container exists before attempting to purge sessions out of it. If the sessions container is NULL, we simply return. Note that this error was also caught by the Asterisk Test Suite. ........ Merged revisions 375800 from http://svn.asterisk.org/svn/asterisk/branches/1.8 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10@375801 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/manager.c b/main/manager.c index 2240582811..34bd8b4dfa 100644 --- a/main/manager.c +++ b/main/manager.c @@ -5221,6 +5221,10 @@ static void purge_sessions(int n_max) time_t now = time(NULL); struct ao2_iterator i; + if (!sessions) { + return; + } + i = ao2_iterator_init(sessions, 0); while ((session = ao2_iterator_next(&i)) && n_max > 0) { ao2_lock(session);