]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix crashes on FSH323Connection calls in on_hangup routine in different threads.
authorroot <root@proxy-2.(none)>
Thu, 16 Sep 2010 16:08:30 +0000 (20:08 +0400)
committerroot <root@proxy-2.(none)>
Thu, 16 Sep 2010 16:08:30 +0000 (20:08 +0400)
src/mod/endpoints/mod_h323/changes.txt
src/mod/endpoints/mod_h323/mod_h323.cpp
src/mod/endpoints/mod_h323/mod_h323.h

index ff477801188a71dd4877425beb68764e386ccccd..19aca46dc8a5b7e5e98571de3a48e0e900979903 100644 (file)
@@ -1,3 +1,4 @@
+fix crashes on FSH323Connection calls in on_hangup routine in different threads.
 move PTrace level set to FSH323EndPoint::Initialise
 partially apply patch from from Peter Olsson, Remove UnLock() when TryLock() failed and DEBUG_RTP_PACKETS directive.
 apply changes from mod_h323-patch.diff by Peter Olsson.
index aeee422ca567d0e42d0646d2874ffa395c130775..142506dd92606255de06856b82ceb1b15781c29c 100644 (file)
@@ -24,7 +24,7 @@
  *
  * mod_h323.cpp -- H323 endpoint
  *
- *     Version 0.0.55
+ *     Version 0.0.56
 */
 
 //#define DEBUG_RTP_PACKETS
@@ -747,6 +747,17 @@ FSH323Connection::~FSH323Connection()
 //     switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
 }      
 
+void FSH323Connection::AttachSignalChannel(const PString & token,
+                                         H323Transport * channel,
+                                         PBoolean answeringCall)
+{
+       h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
+       tech_pvt->token = strdup((const char *)token);
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"---------->token = %s [%p]\n",(const char *)token,this);
+       H323Connection::AttachSignalChannel(token,channel,answeringCall);
+}
+
+
 void FSH323Connection::OnSetLocalCapabilities()
 {
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnSetLocalCapabilities() [%p]\n",this);
@@ -2321,8 +2332,9 @@ static switch_status_t on_hangup(switch_core_session_t *session)
        switch_channel_t *channel = switch_core_session_get_channel(session);
        h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(session);
        FSH323Connection *me = tech_pvt->me;
+       FSH323EndPoint & ep = h323_process->GetH323EndPoint();
        tech_pvt->me = NULL;
-
+    
        if (me) {
                if (me->m_rtp_resetting == 1) {
                        switch_core_session_unlock_codec_read(session);
@@ -2340,12 +2352,12 @@ static switch_status_t on_hangup(switch_core_session_t *session)
                        me->CloseAllLogicalChannels(false);
                        me->Unlock();
                }
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----->%s\n",(const char *)(me->GetCallToken()));
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----->%s\n",(const char *)(tech_pvt->token));
                Q931::CauseValues cause = (Q931::CauseValues)switch_channel_get_cause_q850(channel);
                int trylock = me->TryLock();
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> () = %d\n",trylock);
                if (trylock == 1) {
-                       const PString currentToken(me->GetCallToken());
+                       const PString currentToken(tech_pvt->token);
                        FSH323Connection *connection = (FSH323Connection *)me->GetEndPoint()->FindConnectionWithLock(currentToken); 
                        if (connection) {
                                connection->Unlock();
@@ -2356,8 +2368,10 @@ static switch_status_t on_hangup(switch_core_session_t *session)
                } else if (trylock == -1) {
                        /* Failed to lock - just go on */
                }
+               const PString currentToken(tech_pvt->token);
                me->SetQ931Cause(cause);
-               me->ClearCallSynchronous(NULL, H323TranslateToCallEndReason(cause, UINT_MAX));
+//             me->ClearCallSynchronous(NULL, H323TranslateToCallEndReason(cause, UINT_MAX));
+               ep.ClearCall(currentToken, H323TranslateToCallEndReason(cause, UINT_MAX));
 //             switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_lock\n");
 //             switch_mutex_lock(tech_pvt->h323_mutex);
        }
index 087540c509b3d643c56c2548a6b724a997a60d4b..81272061268e5fde6a8d54e0b1c0c092cafa58cc 100644 (file)
@@ -184,6 +184,7 @@ typedef struct {
        switch_mutex_t *h323_io_mutex;
 
        FSH323Connection *me;
+       char                    *token;
 } h323_private_t;
 
 #define DECLARE_CALLBACK0(name)                           \
@@ -306,7 +307,11 @@ class FSH323Connection:public H323Connection {
                                         unsigned callReference, switch_caller_profile_t *outbound_profile,
                                         switch_core_session_t *fsSession, switch_channel_t *fsChannel);
        ~FSH323Connection();
-
+       virtual void AttachSignalChannel(
+      const PString & token,
+      H323Transport * channel,
+      PBoolean answeringCall
+    );
        virtual H323Channel *CreateRealTimeLogicalChannel(const H323Capability & capability,
                                                        H323Channel::Directions dir,
                                                        unsigned sessionID, const H245_H2250LogicalChannelParameters * param, RTP_QOS * rtpqos = NULL);