fix crashes on FSH323Connection calls in on_hangup routine in different threads.

This commit is contained in:
root 2010-09-16 20:08:30 +04:00
parent 94cf078a4d
commit 19dc1ab0f2
3 changed files with 26 additions and 6 deletions

View File

@ -1,3 +1,4 @@
fix crashes on FSH323Connection calls in on_hangup routine in different threads.
move PTrace level set to FSH323EndPoint::Initialise move PTrace level set to FSH323EndPoint::Initialise
partially apply patch from from Peter Olsson, Remove UnLock() when TryLock() failed and DEBUG_RTP_PACKETS directive. 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. apply changes from mod_h323-patch.diff by Peter Olsson.

View File

@ -24,7 +24,7 @@
* *
* mod_h323.cpp -- H323 endpoint * mod_h323.cpp -- H323 endpoint
* *
* Version 0.0.55 * Version 0.0.56
*/ */
//#define DEBUG_RTP_PACKETS //#define DEBUG_RTP_PACKETS
@ -747,6 +747,17 @@ FSH323Connection::~FSH323Connection()
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n"); // 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() void FSH323Connection::OnSetLocalCapabilities()
{ {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnSetLocalCapabilities() [%p]\n",this); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnSetLocalCapabilities() [%p]\n",this);
@ -2321,6 +2332,7 @@ static switch_status_t on_hangup(switch_core_session_t *session)
switch_channel_t *channel = switch_core_session_get_channel(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); h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(session);
FSH323Connection *me = tech_pvt->me; FSH323Connection *me = tech_pvt->me;
FSH323EndPoint & ep = h323_process->GetH323EndPoint();
tech_pvt->me = NULL; tech_pvt->me = NULL;
if (me) { if (me) {
@ -2340,12 +2352,12 @@ static switch_status_t on_hangup(switch_core_session_t *session)
me->CloseAllLogicalChannels(false); me->CloseAllLogicalChannels(false);
me->Unlock(); 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); Q931::CauseValues cause = (Q931::CauseValues)switch_channel_get_cause_q850(channel);
int trylock = me->TryLock(); int trylock = me->TryLock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> () = %d\n",trylock); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> () = %d\n",trylock);
if (trylock == 1) { if (trylock == 1) {
const PString currentToken(me->GetCallToken()); const PString currentToken(tech_pvt->token);
FSH323Connection *connection = (FSH323Connection *)me->GetEndPoint()->FindConnectionWithLock(currentToken); FSH323Connection *connection = (FSH323Connection *)me->GetEndPoint()->FindConnectionWithLock(currentToken);
if (connection) { if (connection) {
connection->Unlock(); connection->Unlock();
@ -2356,8 +2368,10 @@ static switch_status_t on_hangup(switch_core_session_t *session)
} else if (trylock == -1) { } else if (trylock == -1) {
/* Failed to lock - just go on */ /* Failed to lock - just go on */
} }
const PString currentToken(tech_pvt->token);
me->SetQ931Cause(cause); 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_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_lock\n");
// switch_mutex_lock(tech_pvt->h323_mutex); // switch_mutex_lock(tech_pvt->h323_mutex);
} }

View File

@ -184,6 +184,7 @@ typedef struct {
switch_mutex_t *h323_io_mutex; switch_mutex_t *h323_io_mutex;
FSH323Connection *me; FSH323Connection *me;
char *token;
} h323_private_t; } h323_private_t;
#define DECLARE_CALLBACK0(name) \ #define DECLARE_CALLBACK0(name) \
@ -306,7 +307,11 @@ class FSH323Connection:public H323Connection {
unsigned callReference, switch_caller_profile_t *outbound_profile, unsigned callReference, switch_caller_profile_t *outbound_profile,
switch_core_session_t *fsSession, switch_channel_t *fsChannel); switch_core_session_t *fsSession, switch_channel_t *fsChannel);
~FSH323Connection(); ~FSH323Connection();
virtual void AttachSignalChannel(
const PString & token,
H323Transport * channel,
PBoolean answeringCall
);
virtual H323Channel *CreateRealTimeLogicalChannel(const H323Capability & capability, virtual H323Channel *CreateRealTimeLogicalChannel(const H323Capability & capability,
H323Channel::Directions dir, H323Channel::Directions dir,
unsigned sessionID, const H245_H2250LogicalChannelParameters * param, RTP_QOS * rtpqos = NULL); unsigned sessionID, const H245_H2250LogicalChannelParameters * param, RTP_QOS * rtpqos = NULL);