From 23c9605efb2f68042f0ba002540fd7b1511ad473 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 16 Feb 2017 18:26:26 -0600 Subject: [PATCH] FS-10019 revert and alternate fix --- .../mod_conference/conference_file.c | 4 +- .../mod_conference/conference_video.c | 8 ++-- .../mod_conference/mod_conference.c | 38 ++++--------------- .../mod_conference/mod_conference.h | 1 + 4 files changed, 14 insertions(+), 37 deletions(-) diff --git a/src/mod/applications/mod_conference/conference_file.c b/src/mod/applications/mod_conference/conference_file.c index 230ffb10c9..e64ac1dd86 100644 --- a/src/mod/applications/mod_conference/conference_file.c +++ b/src/mod/applications/mod_conference/conference_file.c @@ -423,7 +423,7 @@ switch_status_t conference_close_open_files(conference_obj_t *conference) { int x = 0; - switch_mutex_lock(conference->mutex); + switch_mutex_lock(conference->file_mutex); /* Close Unused Handles */ if (conference->fnode) { conference_file_node_t *fnode, *cur; @@ -453,7 +453,7 @@ switch_status_t conference_close_open_files(conference_obj_t *conference) switch_core_destroy_memory_pool(&pool); x++; } - switch_mutex_unlock(conference->mutex); + switch_mutex_unlock(conference->file_mutex); return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; } diff --git a/src/mod/applications/mod_conference/conference_video.c b/src/mod/applications/mod_conference/conference_video.c index 6185a2d724..9cc7d6c4ad 100644 --- a/src/mod/applications/mod_conference/conference_video.c +++ b/src/mod/applications/mod_conference/conference_video.c @@ -2465,7 +2465,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr video_count = 0; - switch_mutex_lock(conference->mutex); + switch_mutex_lock(conference->file_mutex); if (conference->async_fnode && switch_core_file_has_video(&conference->async_fnode->fh, SWITCH_TRUE)) { check_async_file = 1; file_count++; @@ -2479,7 +2479,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr video_count++; files_playing = 1; } - switch_mutex_unlock(conference->mutex); + switch_mutex_unlock(conference->file_mutex); switch_mutex_lock(conference->member_mutex); for (imember = conference->members; imember; imember = imember->next) { @@ -2912,7 +2912,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr layout_applied = 0; } - switch_mutex_lock(conference->mutex); + switch_mutex_lock(conference->file_mutex); if (check_async_file && conference->async_fnode) { switch_status_t st = switch_core_file_read_video(&conference->async_fnode->fh, &file_frame, SVR_FLUSH); @@ -2939,7 +2939,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr j++; } } - switch_mutex_unlock(conference->mutex); + switch_mutex_unlock(conference->file_mutex); for (imember = conference->members; imember; imember = imember->next) { int i = 0; diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index ae3777467b..dcb03eec33 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -699,16 +699,19 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob conference_video_canvas_del_fnode_layer(conference, conference->async_fnode); } + switch_mutex_lock(conference->file_mutex); conference_file_close(conference, conference->async_fnode); pool = conference->async_fnode->pool; conference->async_fnode = NULL; switch_core_destroy_memory_pool(&pool); + switch_mutex_unlock(conference->file_mutex); } if (conference->fnode && conference->fnode->done) { conference_file_node_t *fnode; switch_memory_pool_t *pool; + switch_mutex_lock(conference->file_mutex); if (conference->fnode->type != NODE_TYPE_SPEECH) { conference_file_close(conference, conference->fnode); } @@ -717,6 +720,7 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob conference_video_canvas_del_fnode_layer(conference, conference->fnode); } + fnode = conference->fnode; conference->fnode = conference->fnode->next; @@ -728,6 +732,7 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob pool = fnode->pool; fnode = NULL; switch_core_destroy_memory_pool(&pool); + switch_mutex_unlock(conference->file_mutex); } if (!conference->end_count && conference->endconference_time && @@ -821,37 +826,7 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob } } - 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); - } - 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); - } - - switch_mutex_unlock(conference->mutex); + conference_close_open_files(conference); /* Wait till everybody is out */ conference_utils_clear_flag_locked(conference, CFLAG_RUNNING); @@ -3457,6 +3432,7 @@ conference_obj_t *conference_new(char *name, conference_xml_cfg_t cfg, switch_co /* Activate the conference mutex for exclusivity */ switch_mutex_init(&conference->mutex, SWITCH_MUTEX_NESTED, conference->pool); switch_mutex_init(&conference->flag_mutex, SWITCH_MUTEX_NESTED, conference->pool); + switch_mutex_init(&conference->file_mutex, SWITCH_MUTEX_NESTED, conference->pool); switch_thread_rwlock_create(&conference->rwlock, conference->pool); switch_mutex_init(&conference->member_mutex, SWITCH_MUTEX_NESTED, conference->pool); switch_mutex_init(&conference->canvas_mutex, SWITCH_MUTEX_NESTED, conference->pool); diff --git a/src/mod/applications/mod_conference/mod_conference.h b/src/mod/applications/mod_conference/mod_conference.h index 42c1c9f27b..24efb81186 100644 --- a/src/mod/applications/mod_conference/mod_conference.h +++ b/src/mod/applications/mod_conference/mod_conference.h @@ -603,6 +603,7 @@ typedef struct conference_obj { member_flag_t mflags[MFLAG_MAX]; switch_call_cause_t bridge_hangup_cause; switch_mutex_t *flag_mutex; + switch_mutex_t *file_mutex; uint32_t rate; uint32_t interval; uint32_t channels;