[Opalvoip-svn] SF.net SVN: opalvoip:[34896] opal/branches/v3_16
Brought to you by:
csoutheren,
rjongbloed
From: <rjo...@us...> - 2016-07-30 16:27:05
|
Revision: 34896 http://sourceforge.net/p/opalvoip/code/34896 Author: rjongbloed Date: 2016-07-30 16:27:03 +0000 (Sat, 30 Jul 2016) Log Message: ----------- Back ported some changes to fix deadlocks and crashes in media thread handling. Modified Paths: -------------- opal/branches/v3_16/include/opal/mediasession.h opal/branches/v3_16/src/opal/mediasession.cxx opal/branches/v3_16/src/rtp/rtp_session.cxx Modified: opal/branches/v3_16/include/opal/mediasession.h =================================================================== --- opal/branches/v3_16/include/opal/mediasession.h 2016-07-30 16:04:18 UTC (rev 34895) +++ opal/branches/v3_16/include/opal/mediasession.h 2016-07-30 16:27:03 UTC (rev 34896) @@ -461,6 +461,7 @@ PTimeInterval m_mediaTimeout; PSimpleTimer m_mediaTimer; PTimeInterval m_maxNoTransmitTime; + atomic<bool> m_opened; bool m_started; struct Transport Modified: opal/branches/v3_16/src/opal/mediasession.cxx =================================================================== --- opal/branches/v3_16/src/opal/mediasession.cxx 2016-07-30 16:04:18 UTC (rev 34895) +++ opal/branches/v3_16/src/opal/mediasession.cxx 2016-07-30 16:27:03 UTC (rev 34896) @@ -512,6 +512,7 @@ , m_packetSize(2048) , m_mediaTimeout(0, 0, 5) // Nothing received for 5 minutes , m_maxNoTransmitTime(0, 10) // Sending data for 10 seconds, ICMP says still not there + , m_opened(false) , m_started(false) { } @@ -525,15 +526,7 @@ bool OpalMediaTransport::IsOpen() const { - PSafeLockReadOnly lock(*this); - if (!lock.IsLocked() || m_subchannels.empty()) - return false; - - for (vector<Transport>::const_iterator it = m_subchannels.begin(); it != m_subchannels.end(); ++it) { - if (it->m_channel == NULL || !it->m_channel->IsOpen()) - return false; - } - return true; + return m_opened; } @@ -841,7 +834,7 @@ bool OpalTCPMediaTransport::Open(OpalMediaSession &, PINDEX, const PString & localInterface, const OpalTransportAddress &) { - return dynamic_cast<PTCPSocket &>(*m_subchannels[0].m_channel).Listen(PIPAddress(localInterface)); + return m_opened = dynamic_cast<PTCPSocket &>(*m_subchannels[0].m_channel).Listen(PIPAddress(localInterface)); } @@ -1158,6 +1151,7 @@ } m_mediaTimer = m_mediaTimeout; + m_opened = true; return true; } Modified: opal/branches/v3_16/src/rtp/rtp_session.cxx =================================================================== --- opal/branches/v3_16/src/rtp/rtp_session.cxx 2016-07-30 16:04:18 UTC (rev 34895) +++ opal/branches/v3_16/src/rtp/rtp_session.cxx 2016-07-30 16:27:03 UTC (rev 34896) @@ -194,6 +194,7 @@ if (it->second->m_direction == e_Sender) it->second->SendBYE(); + PTRACE(3, *this << "removed " << it->second->m_direction << " SSRC=" << RTP_TRACE_SRC(ssrc)); delete it->second; m_SSRC.erase(it); return true; @@ -207,7 +208,7 @@ return it->second; if ((force || m_allowAnySyncSource) && AddSyncSource(ssrc, dir) == ssrc) { - PTRACE(4, *this << "automatically added " << dir << " SSRC=" << RTP_TRACE_SRC(ssrc)); + PTRACE(4, *this << "automatically added " << GetMediaType() << ' ' << dir << " SSRC=" << RTP_TRACE_SRC(ssrc)); return m_SSRC.find(ssrc)->second; } @@ -781,6 +782,8 @@ void OpalRTPSession::InternalAttachTransport(const OpalMediaTransportPtr & newTransport PTRACE_PARAM(, const char * from)) { OpalMediaSession::AttachTransport(newTransport); + if (!IsOpen()) + return; newTransport->AddReadNotifier(m_dataNotifier, e_Data); if (!m_singlePortRx) @@ -2345,17 +2348,19 @@ { PTRACE(3, *this << "closing RTP."); + m_reportTimer.Stop(true); + m_endpoint.RegisterLocalRTP(this, true); + if (IsOpen() && LockReadOnly()) { for (SyncSourceMap::iterator it = m_SSRC.begin(); it != m_SSRC.end(); ++it) { - if (it->second->m_direction == e_Sender && it->second->m_packets > 0) - it->second->SendBYE(); + if ( it->second->m_direction == e_Sender && + it->second->m_packets > 0 && + it->second->SendBYE() == e_AbortTransport) + break; } UnlockReadOnly(); } - m_reportTimer.Stop(true); - m_endpoint.RegisterLocalRTP(this, true); - return OpalMediaSession::Close(); } @@ -2503,9 +2508,8 @@ CheckMediaFailed(e_Control); } else { - RTP_DataFrame frame; - frame.PBYTEArray::operator=(data); - if (OnReceiveData(frame, data.GetSize()) == e_AbortTransport) + RTP_DataFrame frame(data); + if (OnPreReceiveData(frame) == e_AbortTransport) CheckMediaFailed(e_Data); } } @@ -2618,7 +2622,7 @@ /* Really should test if both data and control fail, but as it is unlikely we would get one failed without the other, we don't bother. */ if (subchannel == e_Data && m_connection.OnMediaFailed(m_sessionId)) { - PTRACE(3, *this << "aborting transport, queuing close of media session."); + PTRACE(2, *this << "aborting transport, queuing close of media session."); m_manager.QueueDecoupledEvent(new PSafeWorkNoArg<OpalRTPSession, bool>(this, &OpalRTPSession::Close)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |