Update VirtualSocketServer locking to match documentation.

Add GUARDED_BY annotation on members claimed to be protected by the
lock, and add missing lock operations. Also mark a few members const.

Bug: webrtc:11567, webrtc:2079
Change-Id: I8f12ca7627df0c24e07fa2ae24a387c6a0ed76cf
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/208224
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34340}
This commit is contained in:
Niels Möller
2021-06-17 16:58:59 +02:00
committed by WebRTC LUCI CQ
parent a4aabb9213
commit 257f81b98e
2 changed files with 54 additions and 43 deletions

View File

@ -400,16 +400,16 @@ class VirtualSocket : public AsyncSocket,
void OnSocketServerReadyToSend();
VirtualSocketServer* server_;
int type_;
bool async_;
VirtualSocketServer* const server_;
const int type_;
const bool async_;
ConnState state_;
int error_;
SocketAddress local_addr_;
SocketAddress remote_addr_;
// Pending sockets which can be Accepted
ListenQueue* listen_queue_;
ListenQueue* listen_queue_ RTC_GUARDED_BY(crit_) RTC_PT_GUARDED_BY(crit_);
// Data which tcp has buffered for sending
SendBuffer send_buffer_;
@ -417,7 +417,7 @@ class VirtualSocket : public AsyncSocket,
// Set back to true when the socket can send again.
bool ready_to_send_ = true;
// Critical section to protect the recv_buffer and queue_
// Critical section to protect the recv_buffer and listen_queue_
RecursiveCriticalSection crit_;
// Network model that enforces bandwidth and capacity constraints
@ -428,7 +428,7 @@ class VirtualSocket : public AsyncSocket,
int64_t last_delivery_time_ = 0;
// Data which has been received from the network
RecvBuffer recv_buffer_;
RecvBuffer recv_buffer_ RTC_GUARDED_BY(crit_);
// The amount of data which is in flight or in recv_buffer_
size_t recv_buffer_size_;