mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Guard GenerateUniqueId aginst concurrent access.
Similar to https://webrtc-review.googlesource.com/c/src/+/147020. Bug: b/264473017 Change-Id: I40a6239f28c01b90f521f3cadcb4aea4f6d6461c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/336180 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41609}
This commit is contained in:
parent
c3624d02d0
commit
cc70a6d174
1 changed files with 4 additions and 1 deletions
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
@ -22,8 +23,10 @@
|
|||
namespace webrtc {
|
||||
|
||||
// This function is only expected to be called on the signalling thread.
|
||||
// On the other hand, some test or even production setups may use
|
||||
// several signaling threads.
|
||||
int RtpReceiverInternal::GenerateUniqueId() {
|
||||
static int g_unique_id = 0;
|
||||
static std::atomic<int> g_unique_id{0};
|
||||
|
||||
return ++g_unique_id;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue