Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(973)

Unified Diff: webrtc/test/channel_transport/udp_socket_posix.cc

Issue 1591333002: Remove dependency on ConditionVariableWrapper and CriticalSectionWrapper in UdpSocketPosix. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove unnecessary fwd decl Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/test/channel_transport/udp_socket_posix.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/test/channel_transport/udp_socket_posix.cc
diff --git a/webrtc/test/channel_transport/udp_socket_posix.cc b/webrtc/test/channel_transport/udp_socket_posix.cc
index 639d444f55e5ddf51ab347e4be6cde4104eddf25..8ed5825dbcc1588a2b6092fdf9b736ee239f6184 100644
--- a/webrtc/test/channel_transport/udp_socket_posix.cc
+++ b/webrtc/test/channel_transport/udp_socket_posix.cc
@@ -27,7 +27,10 @@
namespace webrtc {
namespace test {
UdpSocketPosix::UdpSocketPosix(const int32_t id, UdpSocketManager* mgr,
- bool ipV6Enable) : _id(id)
+ bool ipV6Enable)
+ : _id(id),
+ _closeBlockingCompletedCond(true, false),
+ _readyForDeletionCond(true, false)
{
WEBRTC_TRACE(kTraceMemory, kTraceTransport, id,
"UdpSocketPosix::UdpSocketPosix()");
@@ -37,13 +40,9 @@ UdpSocketPosix::UdpSocketPosix(const int32_t id, UdpSocketManager* mgr,
_obj = NULL;
_incomingCb = NULL;
- _readyForDeletionCond = ConditionVariableWrapper::CreateConditionVariable();
- _closeBlockingCompletedCond =
- ConditionVariableWrapper::CreateConditionVariable();
- _cs = CriticalSectionWrapper::CreateCriticalSection();
_readyForDeletion = false;
_closeBlockingActive = false;
- _closeBlockingCompleted= false;
+ _closeBlockingCompleted = false;
if(ipV6Enable)
{
_socket = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
@@ -75,20 +74,6 @@ UdpSocketPosix::~UdpSocketPosix()
close(_socket);
_socket = INVALID_SOCKET;
}
- if(_readyForDeletionCond)
- {
- delete _readyForDeletionCond;
- }
-
- if(_closeBlockingCompletedCond)
- {
- delete _closeBlockingCompletedCond;
- }
-
- if(_cs)
- {
- delete _cs;
- }
}
bool UdpSocketPosix::SetCallback(CallbackObj obj, IncomingSocketCallback cb)
@@ -227,41 +212,42 @@ bool UdpSocketPosix::WantsIncoming() { return _wantsIncoming; }
void UdpSocketPosix::CloseBlocking()
{
- _cs->Enter();
+ rtc::CritScope lock(&_cs);
_closeBlockingActive = true;
if(!CleanUp())
{
_closeBlockingActive = false;
- _cs->Leave();
return;
}
- while(!_readyForDeletion)
+ if(!_readyForDeletion)
{
- _readyForDeletionCond->SleepCS(*_cs);
+ _cs.Leave();
+ _readyForDeletionCond.Wait(rtc::Event::kForever);
+ _cs.Enter();
}
_closeBlockingCompleted = true;
- _closeBlockingCompletedCond->Wake();
- _cs->Leave();
+ _closeBlockingCompletedCond.Set();
}
void UdpSocketPosix::ReadyForDeletion()
{
- _cs->Enter();
+ rtc::CritScope lock(&_cs);
if(!_closeBlockingActive)
{
- _cs->Leave();
return;
}
+
close(_socket);
_socket = INVALID_SOCKET;
_readyForDeletion = true;
- _readyForDeletionCond->Wake();
- while(!_closeBlockingCompleted)
+ _readyForDeletionCond.Set();
+ if(!_closeBlockingCompleted)
{
- _closeBlockingCompletedCond->SleepCS(*_cs);
+ _cs.Leave();
+ _closeBlockingCompletedCond.Wait(rtc::Event::kForever);
+ _cs.Enter();
}
- _cs->Leave();
}
bool UdpSocketPosix::CleanUp()
« no previous file with comments | « webrtc/test/channel_transport/udp_socket_posix.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698