From f5c541a5c93f75a0349f880954763178924575c6 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 28 Oct 2015 18:32:16 -0500 Subject: [PATCH] fix close file snafu --- .../mod_conference/conference_file.c | 39 +++++++++++++++++++ .../mod_conference/conference_video.c | 2 + .../mod_conference/mod_conference.h | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_conference/conference_file.c b/src/mod/applications/mod_conference/conference_file.c index 45a7913d3f..8ca5b0d754 100644 --- a/src/mod/applications/mod_conference/conference_file.c +++ b/src/mod/applications/mod_conference/conference_file.c @@ -410,6 +410,45 @@ switch_status_t conference_file_local_play(conference_obj_t *conference, switch_ return status; } +switch_status_t conference_close_open_files(conference_obj_t *conference) +{ + int x = 0; + + switch_mutex_lock(conference->mutex); + /* Close Unused Handles */ + if (conference->fnode) { + conference_file_node_t *fnode, *cur; + switch_memory_pool_t *pool; + + fnode = conference->fnode; + while (fnode) { + cur = fnode; + fnode = fnode->next; + + if (cur->type != NODE_TYPE_SPEECH) { + conference_file_close(conference, cur); + } + + pool = cur->pool; + switch_core_destroy_memory_pool(&pool); + x++; + } + conference->fnode = NULL; + } + + if (conference->async_fnode) { + switch_memory_pool_t *pool; + conference_file_close(conference, conference->async_fnode); + pool = conference->async_fnode->pool; + conference->async_fnode = NULL; + switch_core_destroy_memory_pool(&pool); + x++; + } + switch_mutex_unlock(conference->mutex); + + return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; +} + /* For Emacs: * Local Variables: * mode:c diff --git a/src/mod/applications/mod_conference/conference_video.c b/src/mod/applications/mod_conference/conference_video.c index 166b07b9b1..7bdf4611bc 100644 --- a/src/mod/applications/mod_conference/conference_video.c +++ b/src/mod/applications/mod_conference/conference_video.c @@ -2681,6 +2681,8 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr } } + conference_close_open_files(conference); + switch_core_timer_destroy(&canvas->timer); conference_video_destroy_canvas(&canvas); diff --git a/src/mod/applications/mod_conference/mod_conference.h b/src/mod/applications/mod_conference/mod_conference.h index eab3e0ff67..d4dce63481 100644 --- a/src/mod/applications/mod_conference/mod_conference.h +++ b/src/mod/applications/mod_conference/mod_conference.h @@ -860,7 +860,7 @@ void conference_member_add_file_data(conference_member_t *member, int16_t *data, void conference_send_notify(conference_obj_t *conference, const char *status, const char *call_id, switch_bool_t final); switch_status_t conference_file_close(conference_obj_t *conference, conference_file_node_t *node); void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *thread, void *obj); - +switch_status_t conference_close_open_files(conference_obj_t *conference); void conference_al_gen_arc(conference_obj_t *conference, switch_stream_handle_t *stream); void conference_al_process(al_handle_t *al, void *data, switch_size_t datalen, int rate);