]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6051 --resolve mod_rayo - double destroy of output component
authorChris Rienzo <chris.rienzo@grasshopper.com>
Mon, 13 Jan 2014 16:02:22 +0000 (11:02 -0500)
committerChris Rienzo <chris.rienzo@grasshopper.com>
Mon, 13 Jan 2014 16:02:22 +0000 (11:02 -0500)
src/mod/event_handlers/mod_rayo/mod_rayo.h
src/mod/event_handlers/mod_rayo/rayo_components.c
src/mod/event_handlers/mod_rayo/rayo_output_component.c

index 9d0bf05490f1d9ac0effe5c9116ba6f982092c96..d5dcdc4e8db50090b4cb712cc7b3f508bb9bfc4b 100644 (file)
@@ -122,6 +122,8 @@ struct rayo_component {
        const char *client_jid;
        /** external ref */
        const char *ref;
+       /** true if component has completed */
+       int complete;
        /** optional cleanup */
        rayo_actor_cleanup_fn cleanup_fn;
 };
index 7ad96d2a7d3b60d243059d0eacbcd90d994220c4..ac1c66175d8ad35f4825887f822d12ac3db39401 100644 (file)
@@ -112,6 +112,7 @@ iks *rayo_component_create_complete_event(struct rayo_component *component, cons
  */
 void rayo_component_send_complete_event(struct rayo_component *component, iks *response)
 {
+       component->complete = 1;
        RAYO_SEND_REPLY(component, iks_find_attrib(response, "to"), response);
        RAYO_UNLOCK(component);
        RAYO_DESTROY(component);
index 3432bcefbf85184330290bb7849710bace613a1e..b5d24e4e5709e48c16e26d9f20ce55ba070339f7 100644 (file)
@@ -105,15 +105,19 @@ static iks *start_call_output(struct rayo_component *component, switch_core_sess
        if (switch_ivr_displace_session(session, stream.data, 0, "m") == SWITCH_STATUS_SUCCESS) {
                RAYO_UNLOCK(component);
        } else {
-               if (OUTPUT_COMPONENT(component)->document) {
-                       iks_delete(OUTPUT_COMPONENT(component)->document);
-               }
-               if (switch_channel_get_state(switch_core_session_get_channel(session)) >= CS_HANGUP) {
-                       rayo_component_send_complete(component, COMPONENT_COMPLETE_HANGUP);
-                       component = NULL;
+               if (component->complete) {
+                       /* component is already destroyed */
+                       RAYO_UNLOCK(component);
                } else {
-                       rayo_component_send_complete(component, COMPONENT_COMPLETE_ERROR);
-                       component = NULL;
+                       /* need to destroy component */
+                       if (OUTPUT_COMPONENT(component)->document) {
+                               iks_delete(OUTPUT_COMPONENT(component)->document);
+                       }
+                       if (switch_channel_get_state(switch_core_session_get_channel(session)) >= CS_HANGUP) {
+                               rayo_component_send_complete(component, COMPONENT_COMPLETE_HANGUP);
+                       } else {
+                               rayo_component_send_complete(component, COMPONENT_COMPLETE_ERROR);
+                       }
                }
        }
        switch_safe_free(stream.data);