mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
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:
parent
c3a486c41e
commit
6d17602e70
3 changed files with 13 additions and 10 deletions
|
@ -809,6 +809,7 @@ rtc_library("threading") {
|
|||
"../api:function_view",
|
||||
"../api:scoped_refptr",
|
||||
"../api/task_queue",
|
||||
"synchronization:mutex",
|
||||
"synchronization:sequence_checker",
|
||||
"system:no_unique_address",
|
||||
"system:rtc_export",
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/network_monitor.h"
|
||||
#include "rtc_base/null_socket_server.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "rtc_base/time_utils.h"
|
||||
|
||||
#if defined(WEBRTC_LINUX)
|
||||
|
@ -273,12 +274,12 @@ int PhysicalSocket::DoConnect(const SocketAddress& connect_addr) {
|
|||
}
|
||||
|
||||
int PhysicalSocket::GetError() const {
|
||||
CritScope cs(&crit_);
|
||||
webrtc::MutexLock lock(&mutex_);
|
||||
return error_;
|
||||
}
|
||||
|
||||
void PhysicalSocket::SetError(int error) {
|
||||
CritScope cs(&crit_);
|
||||
webrtc::MutexLock lock(&mutex_);
|
||||
error_ = error;
|
||||
}
|
||||
|
||||
|
@ -934,7 +935,7 @@ class EventDispatcher : public Dispatcher {
|
|||
}
|
||||
|
||||
virtual void Signal() {
|
||||
CritScope cs(&crit_);
|
||||
webrtc::MutexLock lock(&mutex_);
|
||||
if (!fSignaled_) {
|
||||
const uint8_t b[1] = {0};
|
||||
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
|
||||
// pipes. This simulates it by resetting before the event is handled.
|
||||
|
||||
CritScope cs(&crit_);
|
||||
webrtc::MutexLock lock(&mutex_);
|
||||
if (fSignaled_) {
|
||||
uint8_t b[4]; // Allow for reading more than 1 byte, but expect 1.
|
||||
const ssize_t res = read(afd_[0], b, sizeof(b));
|
||||
|
@ -965,10 +966,10 @@ class EventDispatcher : public Dispatcher {
|
|||
bool IsDescriptorClosed() override { return false; }
|
||||
|
||||
private:
|
||||
PhysicalSocketServer* ss_;
|
||||
int afd_[2];
|
||||
bool fSignaled_;
|
||||
RecursiveCriticalSection crit_;
|
||||
PhysicalSocketServer* const ss_;
|
||||
int afd_[2]; // Assigned in constructor only.
|
||||
bool fSignaled_ RTC_GUARDED_BY(mutex_);
|
||||
webrtc::Mutex mutex_;
|
||||
};
|
||||
|
||||
#endif // WEBRTC_POSIX
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "rtc_base/async_resolver_interface.h"
|
||||
#include "rtc_base/deprecated/recursive_critical_section.h"
|
||||
#include "rtc_base/socket_server.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "rtc_base/system/rtc_export.h"
|
||||
#include "rtc_base/thread_annotations.h"
|
||||
|
||||
|
@ -203,8 +204,8 @@ class PhysicalSocket : public AsyncSocket, public sigslot::has_slots<> {
|
|||
SOCKET s_;
|
||||
bool udp_;
|
||||
int family_ = 0;
|
||||
RecursiveCriticalSection crit_;
|
||||
int error_ RTC_GUARDED_BY(crit_);
|
||||
mutable webrtc::Mutex mutex_;
|
||||
int error_ RTC_GUARDED_BY(mutex_);
|
||||
ConnState state_;
|
||||
AsyncResolver* resolver_;
|
||||
|
||||
|
|
Loading…
Reference in a new issue