dcsctp: Fix data race in debug logging
The variable instance_count might be accessed from multiple threads when different PeerConnectionFactory objects are used, which may create multiple network threads. This is a pattern mostly noticed in tests. This fixes issues with logging when run under TSAN, it should not have any production impact. Bug: chromium:1243702 Change-Id: Iab1412a7907545811a309cab27a3ae23b4718606 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251983 Auto-Submit: Florent Castelli <orphis@webrtc.org> Reviewed-by: Victor Boivie <boivie@google.com> Commit-Queue: Florent Castelli <orphis@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36045}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
7b0a30ec9a
commit
9bbfe9e5e0
@ -10,6 +10,7 @@
|
||||
|
||||
#include "media/sctp/dcsctp_transport.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
@ -126,7 +127,7 @@ DcSctpTransport::DcSctpTransport(rtc::Thread* network_thread,
|
||||
socket_->HandleTimeout(timeout_id);
|
||||
}) {
|
||||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
static int instance_count = 0;
|
||||
static std::atomic<int> instance_count = 0;
|
||||
rtc::StringBuilder sb;
|
||||
sb << debug_name_ << instance_count++;
|
||||
debug_name_ = sb.Release();
|
||||
|
Reference in New Issue
Block a user