Replace use of RecursiveCriticalSection in VirtualSocketServer Also change listen_queue_ member to use std::unique_ptr to manage ownership. Bug: webrtc:11567 Change-Id: I85171c9cd0253fdbcbce38b1cfebb1adb5bddd9b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/223063 Commit-Queue: Niels Moller <nisse@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34353}
diff --git a/rtc_base/virtual_socket_server.h b/rtc_base/virtual_socket_server.h index a17a6d6..6c58a4bd 100644 --- a/rtc_base/virtual_socket_server.h +++ b/rtc_base/virtual_socket_server.h
@@ -17,11 +17,11 @@ #include "rtc_base/checks.h" #include "rtc_base/constructor_magic.h" -#include "rtc_base/deprecated/recursive_critical_section.h" #include "rtc_base/event.h" #include "rtc_base/fake_clock.h" #include "rtc_base/message_handler.h" #include "rtc_base/socket_server.h" +#include "rtc_base/synchronization/mutex.h" namespace rtc { @@ -394,7 +394,7 @@ typedef std::map<Option, int> OptionsMap; int InitiateConnect(const SocketAddress& addr, bool use_delay); - void CompleteConnect(const SocketAddress& addr, bool notify); + void CompleteConnect(const SocketAddress& addr); int SendUdp(const void* pv, size_t cb, const SocketAddress& addr); int SendTcp(const void* pv, size_t cb); @@ -409,7 +409,8 @@ SocketAddress remote_addr_; // Pending sockets which can be Accepted - ListenQueue* listen_queue_ RTC_GUARDED_BY(crit_) RTC_PT_GUARDED_BY(crit_); + std::unique_ptr<ListenQueue> listen_queue_ RTC_GUARDED_BY(mutex_) + RTC_PT_GUARDED_BY(mutex_); // Data which tcp has buffered for sending SendBuffer send_buffer_; @@ -417,8 +418,8 @@ // Set back to true when the socket can send again. bool ready_to_send_ = true; - // Critical section to protect the recv_buffer and listen_queue_ - RecursiveCriticalSection crit_; + // Mutex to protect the recv_buffer and listen_queue_ + webrtc::Mutex mutex_; // Network model that enforces bandwidth and capacity constraints NetworkQueue network_; @@ -428,7 +429,7 @@ int64_t last_delivery_time_ = 0; // Data which has been received from the network - RecvBuffer recv_buffer_ RTC_GUARDED_BY(crit_); + RecvBuffer recv_buffer_ RTC_GUARDED_BY(mutex_); // The amount of data which is in flight or in recv_buffer_ size_t recv_buffer_size_;