From: Anthony Minessale Date: Sun, 22 Mar 2009 18:35:55 +0000 (+0000) Subject: tweak lua hangup hook (part 2) X-Git-Tag: v1.0.4~1434 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=749c21775a5e96947ba0f3a9d98445d125fa0b80;p=thirdparty%2Ffreeswitch.git tweak lua hangup hook (part 2) git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12714 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- diff --git a/src/mod/languages/mod_lua/freeswitch_lua.cpp b/src/mod/languages/mod_lua/freeswitch_lua.cpp index 0f7ef7750a..63242a2e55 100644 --- a/src/mod/languages/mod_lua/freeswitch_lua.cpp +++ b/src/mod/languages/mod_lua/freeswitch_lua.cpp @@ -24,6 +24,10 @@ static switch_status_t lua_hanguphook(switch_core_session_t *session_hungup); Session::~Session() { + if (channel) { + switch_channel_set_private(channel, "CoreSession", NULL); + } + if (hangup_func_str) { if (session) { switch_core_event_hook_remove_state_change(session, lua_hanguphook); @@ -141,6 +145,10 @@ static switch_status_t lua_hanguphook(switch_core_session_t *session_hungup) coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"); } + if (!(coresession && coresession->hook_state)) { + return SWITCH_STATUS_FALSE; + } + if (coresession && coresession->allocated && (state == CS_HANGUP || state == CS_ROUTING) && coresession->hook_state != state) { coresession->hook_state = state; coresession->check_hangup_hook();