]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FSCORE-508
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 7 Dec 2009 16:40:42 +0000 (16:40 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 7 Dec 2009 16:40:42 +0000 (16:40 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15830 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_cpp.cpp

index b19642c277e56c9b276fc0bffffc8b6def239724..009e74240477c618399a4416355cc443fe693bec 100644 (file)
@@ -515,7 +515,7 @@ SWITCH_DECLARE_CONSTRUCTOR CoreSession::CoreSession(switch_core_session_t *new_s
 SWITCH_DECLARE_CONSTRUCTOR CoreSession::~CoreSession()
 {
        this_check_void();
-       destroy();
+       if (allocated) destroy();
 }
 
 SWITCH_DECLARE(char *) CoreSession::getXMLCDR()
@@ -918,6 +918,8 @@ SWITCH_DECLARE(void) CoreSession::destroy(void)
                return;
        }
 
+       allocated = 0;
+
        switch_safe_free(xml_cdr_text);
        switch_safe_free(uuid); 
        switch_safe_free(tts_name);
@@ -929,14 +931,14 @@ SWITCH_DECLARE(void) CoreSession::destroy(void)
                }
 
                if (channel) {
+                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, 
+                                                         "%s destroy/unlink session from object\n", switch_channel_get_name(channel));
                        switch_channel_set_private(channel, "CoreSession", NULL);
+                       if (switch_channel_up(channel) && switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) {
+                               switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+                       }
                }
-               
-               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "destroy/unlink session from object\n");
-               
-        if (switch_channel_up(channel) && switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) {
-            switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
-        }
+
         switch_core_session_rwunlock(session);
                session = NULL;
                channel = NULL;