]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
tweak lua hangup hook
authorAnthony Minessale <anthony.minessale@gmail.com>
Sun, 22 Mar 2009 18:23:24 +0000 (18:23 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Sun, 22 Mar 2009 18:23:24 +0000 (18:23 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12713 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/languages/mod_lua/freeswitch_lua.cpp

index e30eb8b6975e6cbb3055aab9c8d793e5e9a611c8..0f7ef7750ad385dd32d41b6d9473aa3b63ac99e4 100644 (file)
@@ -133,10 +133,18 @@ static switch_status_t lua_hanguphook(switch_core_session_t *session_hungup)
        CoreSession *coresession = NULL;
        switch_channel_state_t state = switch_channel_get_state(channel);
 
-       if ((coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"))) {
-               if (coresession->hook_state != state) {
+       if (session_hungup) {
+
+               channel = switch_core_session_get_channel(session_hungup);
+
+               if (channel) {
+                       coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession");
+               }
+               
+               if (coresession && coresession->allocated && (state == CS_HANGUP || state == CS_ROUTING) && coresession->hook_state != state) {
                        coresession->hook_state = state;
                        coresession->check_hangup_hook();
+                       switch_core_event_hook_remove_state_change(session_hungup, lua_hanguphook);
                }
        }