Skip to content

[BUG] Make Thread Counter Thread Safe #2973

@maxsharabayko

Description

@maxsharabayko

The int srt::CSndQueue::m_counter is just a global variable used to construct a name for a thread. However, it is not thread safe unlike srt::sync::atomic<int> srt::CRcvQueue::m_counter(0).

Even though the CRcvQueue::m_counter is atomic, some weird thread names were observed on a platform (MX4) not supporting atomics directly, but using the atomic primitives supplied by srt in atomic.h as a fallback solution.

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
<snip>
17214 root      -3   0 3958m 367m  13m S    0 27.1   0:20.97 SRT:SndQ:w31728    
17215 root      -3   0 3958m 367m  13m S    0 27.1   6:58.34 SRT:RcvQ:w31728    
17216 root      -3   0 3958m 367m  13m S    0 27.1   0:21.14 SRT:SndQ:w31728    
17217 root      -3   0 3958m 367m  13m S    0 27.1   6:52.99 SRT:RcvQ:w31728    
13778 root      -3   0 3958m 367m  13m S    0 27.1   0:00.00 SRT:SndQ:w40781    
13779 root      -3   0 3958m 367m  13m S    0 27.1   0:00.00 SRT:RcvQ:w40781    
13780 root      -3   0 3958m 367m  13m S    0 27.1   0:00.00 SRT:SndQ:w40781    
13781 root      -3   0 3958m 367m  13m S    0 27.1   0:00.00 SRT:RcvQ:w40781    
13782 root      -3   0 3958m 367m  13m S    0 27.1   0:00.00 SRT:SndQ:w40781    
13783 root      -3   0 3958m 367m  13m S    0 27.1   0:00.00 SRT:RcvQ:w40781

SRT v1.5.3a.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugIndicates an unexpected problem or unintended behavior[core]Area: Changes in SRT library core

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions