]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-2879
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 17 Dec 2010 22:06:11 +0000 (16:06 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 17 Dec 2010 22:06:11 +0000 (16:06 -0600)
src/mod/applications/mod_fifo/mod_fifo.c

index 3943ac6ea6703743e52361a1371cc436bd3132d3..f275363706333e08bdc2c08ae7e1f9deb47a9f99 100644 (file)
@@ -3075,16 +3075,24 @@ SWITCH_STANDARD_APP(fifo_function)
   done:
 
        switch_mutex_lock(globals.mutex);
-       if (node && node->ready == FIFO_DELAY_DESTROY && node->consumer_count == 0 && node_caller_count(node) == 0) {
-               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "%s removed.\n", node->name);
-               switch_core_hash_delete(globals.fifo_hash, node->name);
+       if (node && node->ready == FIFO_DELAY_DESTROY) {
+               int doit = 0;
+
                switch_thread_rwlock_wrlock(node->rwlock);
-               node->ready = 0;
-               switch_mutex_lock(node->mutex);
-               switch_core_hash_destroy(&node->consumer_hash);
-               switch_mutex_unlock(node->mutex);
+               doit = node->consumer_count == 0 && node_caller_count(node) == 0;
                switch_thread_rwlock_unlock(node->rwlock);
-               switch_core_destroy_memory_pool(&node->pool);
+
+               if (doit) {
+                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "%s removed.\n", node->name);
+                       switch_core_hash_delete(globals.fifo_hash, node->name);
+
+                       node->ready = 0;
+                       switch_mutex_lock(node->mutex);
+                       switch_core_hash_destroy(&node->consumer_hash);
+                       switch_mutex_unlock(node->mutex);
+                       switch_thread_rwlock_unlock(node->rwlock);
+                       switch_core_destroy_memory_pool(&node->pool);
+               }
 
        }
        switch_mutex_unlock(globals.mutex);