From 0ea742d33a89c8d1d3b92eceb833cbe79faab954 Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Tue, 29 Mar 2016 13:47:08 -0500 Subject: res_stasis: Add control ref to playback and recording structs. The stasis_app_playback and stasis_app_recording structs need to have a struct stasis_app_control ref. Other threads can get a reference to the playback and recording structs from their respective global container. These other threads can then use the control pointer they contain after the control struct has gone. * Add control ref to stasis_app_playback and stasis_app_recording structs. With the refs added, the control command queue can now have a circular control reference which will cause the control struct to never get released if the control's command queue is not flushed when the channel leaves the Stasis application. Also the command queue needs better protection from adding commands if the control->is_done flag is set. * Flush the control command queue on exit. ASTERISK-25882 #close Change-Id: I3cf1fb59cbe6f50f20d9e35a2c07ac07d7f4320d --- res/res_stasis.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'res/res_stasis.c') diff --git a/res/res_stasis.c b/res/res_stasis.c index dc469c8cc..5afb90e3c 100644 --- a/res/res_stasis.c +++ b/res/res_stasis.c @@ -1179,6 +1179,11 @@ int stasis_app_control_is_done(struct stasis_app_control *control) return control_is_done(control); } +void stasis_app_control_flush_queue(struct stasis_app_control *control) +{ + control_flush_queue(control); +} + struct ast_datastore_info set_end_published_info = { .type = "stasis_end_published", }; @@ -1371,6 +1376,8 @@ int stasis_app_exec(struct ast_channel *chan, const char *app_name, int argc, remove_stasis_end_published(chan); } + control_flush_queue(control); + /* Stop any lingering silence generator */ control_silence_stop_now(control); -- cgit v1.2.3