[Freeswitch-trunk] [commit] r14011 - in freeswitch/trunk/contrib/mod/endpoints/mod_khomp: . include

FreeSWITCH SVN raulfragoso at freeswitch.org
Fri Jun 26 23:47:06 PDT 2009


Author: raulfragoso
Date: Sat Jun 27 01:47:06 2009
New Revision: 14011

Log:
No more crashes !

Modified:
   freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h
   freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp

Modified: freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h
==============================================================================
--- freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h	(original)
+++ freeswitch/trunk/contrib/mod/endpoints/mod_khomp/include/khomp_pvt.h	Sat Jun 27 01:47:06 2009
@@ -54,6 +54,7 @@
                 K3LAPI::target tgt(Globals::_k3lapi, K3LAPI::target::CHANNEL, dev, obj);
                 KhompPvt * pvt = new KhompPvt(tgt);
                 _pvts.back().push_back(pvt);
+                Globals::_k3lapi.command(dev, obj, CM_DISCONNECT, NULL); 
             }
         }
     }

Modified: freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp
==============================================================================
--- freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp	(original)
+++ freeswitch/trunk/contrib/mod/endpoints/mod_khomp/mod_khomp.cpp	Sat Jun 27 01:47:06 2009
@@ -1048,17 +1048,23 @@
             }
             break;
         case EV_DISCONNECT:
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Called party dropped the call on: %u. Releasing channel. [EV_DISCONNECT]\n", obj);
-            if (channel_on_hangup(KhompPvt::khompPvt(e->DeviceId, obj)->session()) != SWITCH_STATUS_SUCCESS)
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not hangup channel: %u on board %u. Releasing board channel anyway. [EV_DISCONNECT]\n", obj, e->DeviceId);
-            try
-            {
-                Globals::_k3lapi.command(e->DeviceId, obj, CM_DISCONNECT, NULL);
-                KhompPvt::khompPvt(e->DeviceId, obj)->session(NULL);
-            }
-            catch(K3LAPI::invalid_channel & err)
             {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not send CM_DISCONNECT!\n");
+                switch_core_session_t * session = KhompPvt::khompPvt(e->DeviceId, obj)->session();
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Called party dropped the call on: %u. Releasing channel. [EV_DISCONNECT]\n", obj);
+                if(session == NULL)
+                    break;
+
+                if (channel_on_hangup(session) != SWITCH_STATUS_SUCCESS)
+                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not hangup channel: %u on board %u. Releasing board channel anyway. [EV_DISCONNECT]\n", obj, e->DeviceId);
+                try
+                {
+                    Globals::_k3lapi.command(e->DeviceId, obj, CM_DISCONNECT, NULL);
+                    KhompPvt::khompPvt(e->DeviceId, obj)->session(NULL);
+                }
+                catch(K3LAPI::invalid_channel & err)
+                {
+                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not send CM_DISCONNECT!\n");
+                }
             }
             break;
         case EV_CONNECT:



More information about the Freeswitch-trunk mailing list