]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Don't attempt to purge sessions when no sessions exist
authorMatthew Jordan <mjordan@digium.com>
Sun, 4 Nov 2012 03:06:49 +0000 (03:06 +0000)
committerMatthew Jordan <mjordan@digium.com>
Sun, 4 Nov 2012 03:06:49 +0000 (03:06 +0000)
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.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@375800 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/manager.c

index b02bb46e7c507ec1e24cad736fd8bb81283eaa66..d9577a00cdc43bef7b5dfc244164e9b165f98e68 100644 (file)
@@ -5077,6 +5077,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);