]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11973: [mod_event_multicast] add mutex and checks on hash ptrs on shutdown
authorDragos Oancea <dragos@signalwire.com>
Thu, 1 Aug 2019 18:05:00 +0000 (18:05 +0000)
committerDragos Oancea <dragos@signalwire.com>
Thu, 1 Aug 2019 18:12:39 +0000 (18:12 +0000)
src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c

index 3a5c011996666078fd9c0bd06dab1673db34a724..7fe2911ba684e0317346c57f502c2252db92ea31 100644 (file)
@@ -493,6 +493,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_event_multicast_shutdown)
        globals.running = 0;
        switch_event_unbind_callback(event_handler);
 
+       switch_mutex_lock(globals.mutex);
        if (globals.udp_socket) {
                switch_socket_shutdown(globals.udp_socket, 2);
        }
@@ -501,11 +502,16 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_event_multicast_shutdown)
        switch_event_free_subclass(MULTICAST_PEERUP);
        switch_event_free_subclass(MULTICAST_PEERDOWN);
 
-       switch_core_hash_destroy(&globals.event_hash);
-       switch_core_hash_destroy(&globals.peer_hash);
+       if (globals.event_hash) {
+               switch_core_hash_destroy(&globals.event_hash);
+       }
+       if (globals.peer_hash) {
+               switch_core_hash_destroy(&globals.peer_hash);
+       }
 
        switch_safe_free(globals.address);
        switch_safe_free(globals.bindings);
+       switch_mutex_unlock(globals.mutex);
 
        return SWITCH_STATUS_SUCCESS;
 }