fixing the racing conditions

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1025 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
xians@webrtc.org 2011-11-25 10:58:15 +00:00
parent 859626570a
commit 83661f534e

View File

@ -250,13 +250,16 @@ Channel::SendRTCPPacket(int channel, const void *data, int len)
WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::SendRTCPPacket(channel=%d, len=%d)", channel, len);
if (_transportPtr == NULL)
{
WEBRTC_TRACE(kTraceError, kTraceVoice,
VoEId(_instanceId,_channelId),
"Channel::SendRTCPPacket() failed to send RTCP packet"
" due to invalid transport object");
return -1;
CriticalSectionScoped cs(_callbackCritSect);
if (_transportPtr == NULL)
{
WEBRTC_TRACE(kTraceError, kTraceVoice,
VoEId(_instanceId,_channelId),
"Channel::SendRTCPPacket() failed to send RTCP packet"
" due to invalid transport object");
return -1;
}
}
WebRtc_UWord8* bufferToSendPtr = (WebRtc_UWord8*)data;
@ -1532,7 +1535,12 @@ Channel::Init()
#ifndef WEBRTC_EXTERNAL_TRANSPORT
// Ensure that the WebRtcSocketTransport implementation is used as
// Transport on the sending side
_transportPtr = &_socketTransportModule;
{
// A lock is needed here since users can call
// RegisterExternalTransport() at the same time.
CriticalSectionScoped cs(_callbackCritSect);
_transportPtr = &_socketTransportModule;
}
#endif
// Initialize the far end AP module
@ -2803,6 +2811,8 @@ Channel::DeRegisterExternalTransport()
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::DeRegisterExternalTransport()");
CriticalSectionScoped cs(_callbackCritSect);
if (!_transportPtr)
{
_engineStatisticsPtr->SetLastError(