Replace some RecursiveCriticalSection with Mutex, in PhysicalSocketServer.
The one remaining RecursiveCriticalSection likely needs a bit more care. Bug: webrtc:11567 Change-Id: Ie81085969197bed03ac8e2d269b58653b86095e0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/206468 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Markus Handell <handellm@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33206}
This commit is contained in:
@ -809,6 +809,7 @@ rtc_library("threading") {
|
|||||||
"../api:function_view",
|
"../api:function_view",
|
||||||
"../api:scoped_refptr",
|
"../api:scoped_refptr",
|
||||||
"../api/task_queue",
|
"../api/task_queue",
|
||||||
|
"synchronization:mutex",
|
||||||
"synchronization:sequence_checker",
|
"synchronization:sequence_checker",
|
||||||
"system:no_unique_address",
|
"system:no_unique_address",
|
||||||
"system:rtc_export",
|
"system:rtc_export",
|
||||||
|
|||||||
@ -48,6 +48,7 @@
|
|||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/network_monitor.h"
|
#include "rtc_base/network_monitor.h"
|
||||||
#include "rtc_base/null_socket_server.h"
|
#include "rtc_base/null_socket_server.h"
|
||||||
|
#include "rtc_base/synchronization/mutex.h"
|
||||||
#include "rtc_base/time_utils.h"
|
#include "rtc_base/time_utils.h"
|
||||||
|
|
||||||
#if defined(WEBRTC_LINUX)
|
#if defined(WEBRTC_LINUX)
|
||||||
@ -273,12 +274,12 @@ int PhysicalSocket::DoConnect(const SocketAddress& connect_addr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int PhysicalSocket::GetError() const {
|
int PhysicalSocket::GetError() const {
|
||||||
CritScope cs(&crit_);
|
webrtc::MutexLock lock(&mutex_);
|
||||||
return error_;
|
return error_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicalSocket::SetError(int error) {
|
void PhysicalSocket::SetError(int error) {
|
||||||
CritScope cs(&crit_);
|
webrtc::MutexLock lock(&mutex_);
|
||||||
error_ = error;
|
error_ = error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -934,7 +935,7 @@ class EventDispatcher : public Dispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void Signal() {
|
virtual void Signal() {
|
||||||
CritScope cs(&crit_);
|
webrtc::MutexLock lock(&mutex_);
|
||||||
if (!fSignaled_) {
|
if (!fSignaled_) {
|
||||||
const uint8_t b[1] = {0};
|
const uint8_t b[1] = {0};
|
||||||
const ssize_t res = write(afd_[1], b, sizeof(b));
|
const ssize_t res = write(afd_[1], b, sizeof(b));
|
||||||
@ -949,7 +950,7 @@ class EventDispatcher : public Dispatcher {
|
|||||||
// It is not possible to perfectly emulate an auto-resetting event with
|
// It is not possible to perfectly emulate an auto-resetting event with
|
||||||
// pipes. This simulates it by resetting before the event is handled.
|
// pipes. This simulates it by resetting before the event is handled.
|
||||||
|
|
||||||
CritScope cs(&crit_);
|
webrtc::MutexLock lock(&mutex_);
|
||||||
if (fSignaled_) {
|
if (fSignaled_) {
|
||||||
uint8_t b[4]; // Allow for reading more than 1 byte, but expect 1.
|
uint8_t b[4]; // Allow for reading more than 1 byte, but expect 1.
|
||||||
const ssize_t res = read(afd_[0], b, sizeof(b));
|
const ssize_t res = read(afd_[0], b, sizeof(b));
|
||||||
@ -965,10 +966,10 @@ class EventDispatcher : public Dispatcher {
|
|||||||
bool IsDescriptorClosed() override { return false; }
|
bool IsDescriptorClosed() override { return false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PhysicalSocketServer* ss_;
|
PhysicalSocketServer* const ss_;
|
||||||
int afd_[2];
|
int afd_[2]; // Assigned in constructor only.
|
||||||
bool fSignaled_;
|
bool fSignaled_ RTC_GUARDED_BY(mutex_);
|
||||||
RecursiveCriticalSection crit_;
|
webrtc::Mutex mutex_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WEBRTC_POSIX
|
#endif // WEBRTC_POSIX
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
#include "rtc_base/async_resolver_interface.h"
|
#include "rtc_base/async_resolver_interface.h"
|
||||||
#include "rtc_base/deprecated/recursive_critical_section.h"
|
#include "rtc_base/deprecated/recursive_critical_section.h"
|
||||||
#include "rtc_base/socket_server.h"
|
#include "rtc_base/socket_server.h"
|
||||||
|
#include "rtc_base/synchronization/mutex.h"
|
||||||
#include "rtc_base/system/rtc_export.h"
|
#include "rtc_base/system/rtc_export.h"
|
||||||
#include "rtc_base/thread_annotations.h"
|
#include "rtc_base/thread_annotations.h"
|
||||||
|
|
||||||
@ -203,8 +204,8 @@ class PhysicalSocket : public AsyncSocket, public sigslot::has_slots<> {
|
|||||||
SOCKET s_;
|
SOCKET s_;
|
||||||
bool udp_;
|
bool udp_;
|
||||||
int family_ = 0;
|
int family_ = 0;
|
||||||
RecursiveCriticalSection crit_;
|
mutable webrtc::Mutex mutex_;
|
||||||
int error_ RTC_GUARDED_BY(crit_);
|
int error_ RTC_GUARDED_BY(mutex_);
|
||||||
ConnState state_;
|
ConnState state_;
|
||||||
AsyncResolver* resolver_;
|
AsyncResolver* resolver_;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user