switch_status_t mod_amqp_logging_destroy(mod_amqp_logging_profile_t **prof) { mod_amqp_message_t *msg = NULL; switch_status_t status = SWITCH_STATUS_SUCCESS; mod_amqp_connection_t *conn = NULL, *conn_next = NULL; switch_memory_pool_t *pool; mod_amqp_logging_profile_t *profile; if (!prof || !*prof) { return SWITCH_STATUS_SUCCESS; } profile = *prof; pool = profile->pool; if (profile->name) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Profile[%s] shutting down...\n", profile->name); switch_core_hash_delete(globals.logging_hash, profile->name); } profile->running = 0; if (profile->logging_thread) { switch_thread_join(&status, profile->logging_thread); } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Profile[%s] closing AMQP socket...\n", profile->name); for (conn = profile->conn_root; conn; conn = conn_next) { conn_next = conn->next; mod_amqp_connection_destroy(&conn); } profile->conn_active = NULL; profile->conn_root = NULL; while (profile->send_queue && switch_queue_trypop(profile->send_queue, (void**)&msg) == SWITCH_STATUS_SUCCESS) { mod_amqp_util_msg_destroy(&msg); } if (pool) { switch_core_destroy_memory_pool(&pool); } *prof = NULL; return SWITCH_STATUS_SUCCESS; }
switch_status_t mod_amqp_command_destroy(mod_amqp_command_profile_t **prof) { switch_status_t ret; mod_amqp_connection_t *conn = NULL, *conn_next = NULL; switch_memory_pool_t *pool; mod_amqp_command_profile_t *profile; if (!prof || !*prof) { return SWITCH_STATUS_SUCCESS; } profile = *prof; pool = profile->pool; if (profile->name) { switch_core_hash_delete(globals.command_hash, profile->name); } profile->running = 0; if (profile->command_thread) { switch_thread_join(&ret, profile->command_thread); } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Profile[%s] closing AMQP socket...\n", profile->name); for (conn = profile->conn_root; conn; conn = conn_next) { mod_amqp_connection_destroy(&conn); } profile->conn_active = NULL; profile->conn_root = NULL; if (pool) { switch_core_destroy_memory_pool(&pool); } *prof = NULL; return SWITCH_STATUS_SUCCESS; }