Chromium Code Reviews| Index: webrtc/test/channel_transport/udp_socket2_win.cc |
| diff --git a/webrtc/test/channel_transport/udp_socket2_win.cc b/webrtc/test/channel_transport/udp_socket2_win.cc |
| index adeb46a9d2d064daae7515a590ac8564cf1e6587..4d365fd31386129d0bb5237367aaa5e60a677612 100644 |
| --- a/webrtc/test/channel_transport/udp_socket2_win.cc |
| +++ b/webrtc/test/channel_transport/udp_socket2_win.cc |
| @@ -50,6 +50,7 @@ UdpSocket2Windows::UdpSocket2Windows(const int32_t id, |
| _outstandingCallComplete(0), |
| _terminate(false), |
| _addedToMgr(false), |
| + delete_event_(true, false), |
| _safeTodelete(false), |
| _outstandingCallsDisabled(false), |
| _clientHandle(NULL), |
| @@ -69,12 +70,9 @@ UdpSocket2Windows::UdpSocket2Windows(const int32_t id, |
| _obj = NULL; |
| _incomingCb = NULL; |
| _socket = INVALID_SOCKET; |
| - _pCrit = CriticalSectionWrapper::CreateCriticalSection(); |
| _ptrCbRWLock = RWLockWrapper::CreateRWLock(); |
| _ptrDestRWLock = RWLockWrapper::CreateRWLock(); |
| _ptrSocketRWLock = RWLockWrapper::CreateRWLock(); |
| - _ptrDeleteCrit = CriticalSectionWrapper::CreateCriticalSection(); |
| - _ptrDeleteCond = ConditionVariableWrapper::CreateConditionVariable(); |
| // Check if QoS is supported. |
| BOOL bProtocolFound = FALSE; |
| @@ -188,14 +186,9 @@ UdpSocket2Windows::~UdpSocket2Windows() |
| WaitForOutstandingCalls(); |
| delete _ptrCbRWLock; |
| - delete _ptrDeleteCrit; |
| - delete _ptrDeleteCond; |
| delete _ptrDestRWLock; |
| delete _ptrSocketRWLock; |
| - if(_pCrit) |
| - delete _pCrit; |
| - |
| if (_flow) |
| { |
| free(_flow); |
| @@ -1279,9 +1272,8 @@ void UdpSocket2Windows::OutstandingCallCompleted() |
| { |
| // Only one thread will enter here. The thread with the last outstanding |
| // call. |
| - CriticalSectionScoped cs(_ptrDeleteCrit); |
| _safeTodelete = true; |
| - _ptrDeleteCond->Wake(); |
| + delete_event_.Set(); |
| } |
| } |
| @@ -1302,19 +1294,15 @@ void UdpSocket2Windows::DisableNewOutstandingCalls() |
| if(noOutstandingCalls) |
| { |
| - CriticalSectionScoped cs(_ptrDeleteCrit); |
| _safeTodelete = true; |
| - _ptrDeleteCond->Wake(); |
| + delete_event_.Set(); |
| } |
| } |
| void UdpSocket2Windows::WaitForOutstandingCalls() |
| { |
| - CriticalSectionScoped cs(_ptrDeleteCrit); |
| - while(!_safeTodelete) |
| - { |
| - _ptrDeleteCond->SleepCS(*_ptrDeleteCrit); |
| - } |
| + if (!_safeTodelete) |
|
pbos-webrtc
2016/01/19 20:36:51
Racy read, this was protected by the critical sect
pbos-webrtc
2016/01/19 20:41:09
OTOH, just remove this variable, the event is stil
tommi
2016/01/19 21:06:25
Yes, will do.
This code is riddled with races thou
|
| + delete_event_.Wait(rtc::Event::kForever); |
| } |
| void UdpSocket2Windows::RemoveSocketFromManager() |