Fixed bug: start transport worker thread after init to make sure data is initialized. Fixes incoming tcp transport race condition.

git-svn-id: http://yate.null.ro/svn/yate/trunk@5600 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
marian 2013-08-02 11:11:38 +00:00
parent a0b11fc63d
commit 9a13938320
1 changed files with 22 additions and 7 deletions

View File

@ -366,6 +366,8 @@ protected:
// Status changed notification for descendents
virtual void statusChanged()
{}
// Start the worker thread
bool startWorker(Thread::Priority prio);
// Change transport status. Notify it
void changeStatus(int stat);
// Handle received messages, set party, add to engine
@ -2542,13 +2544,7 @@ bool YateSIPTransport::init(const NamedList& params, const NamedList& defs,
m_sock->getSockName(m_local);
m_sock->getPeerName(m_remote);
}
m_worker = new YateSIPTransportWorker(this,prio);
if (m_worker->startup())
return true;
Debug(&plugin,DebugWarn,"Transport(%s) failed to start worker thread [%p]",m_id.c_str(),this);
m_reason = "Failed to start worker";
m_worker = 0;
return false;
return true;
}
void YateSIPTransport::printSendMsg(const SIPMessage* msg, const SocketAddr* addr)
@ -2666,6 +2662,21 @@ void YateSIPTransport::destroyed()
RefObject::destroyed();
}
// Start the worker thread
bool YateSIPTransport::startWorker(Thread::Priority prio)
{
Lock lck(this);
if (m_worker)
return true;
m_worker = new YateSIPTransportWorker(this,prio);
if (m_worker->startup())
return true;
Debug(&plugin,DebugWarn,"Transport(%s) failed to start worker thread [%p]",m_id.c_str(),this);
m_reason = "Failed to start worker";
m_worker = 0;
return false;
}
// Change transport status. Notify it
void YateSIPTransport::changeStatus(int stat)
{
@ -2801,6 +2812,8 @@ bool YateSIPUDPTransport::init(const NamedList& params, const NamedList& defs, b
"Transport(%s) initialized addr='%s:%d' default=%s maxpkt=%u rtp_localip=%s nat_address=%s [%p]",
m_id.c_str(),m_address.c_str(),m_port,String::boolText(m_default),m_maxpkt,
m_rtpLocalAddr.c_str(),m_rtpNatAddr.c_str(),this);
if (ok && first)
ok = startWorker(prio);
return ok;
}
@ -2973,6 +2986,8 @@ bool YateSIPTCPTransport::init(const NamedList& params, bool first, Thread::Prio
Debug(&plugin,DebugAll,
"Transport(%s) initialized maxpkt=%u rtp_localip=%s nat_address=%s tcp_idle=%u [%p]",
m_id.c_str(),m_maxpkt,m_rtpLocalAddr.c_str(),m_rtpNatAddr.c_str(),m_idleInterval,this);
if (ok && first)
ok = startWorker(prio);
return ok;
}