mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-02-25 01:40:36 -05:00
pod: fix some data races in body code
The body code didn't use atomic loads, so it had undefined behavior if the body was concurrently modified. Use atomic loads to fix this. Since the memory order is __ATOMIC_RELAXED this has no runtime overhead. Also add barriers around a strncpy call and cast to volatile before checking for a NUL terminator, though NUL-terminated strings in shared memory are unuseable. There are some places where bytewise atomic memcpy(), which doesn't currently exist, is needed. Instead, try to fake it by using two barriers around memcpy().
This commit is contained in:
parent
c9c7552fed
commit
bac3d31283
3 changed files with 45 additions and 17 deletions
|
|
@ -19,6 +19,8 @@ extern "C" {
|
|||
#define SPA_ATOMIC_DEC(s) __atomic_sub_fetch(&(s), 1, __ATOMIC_SEQ_CST)
|
||||
#define SPA_ATOMIC_INC(s) __atomic_add_fetch(&(s), 1, __ATOMIC_SEQ_CST)
|
||||
#define SPA_ATOMIC_LOAD(s) __atomic_load_n(&(s), __ATOMIC_SEQ_CST)
|
||||
#define SPA_LOAD_ONCE(s) __atomic_load_n((s), __ATOMIC_RELAXED)
|
||||
#define SPA_STORE_ONCE(s) __atomic_store_n((s), __ATOMIC_RELAXED)
|
||||
#define SPA_ATOMIC_STORE(s,v) __atomic_store_n(&(s), (v), __ATOMIC_SEQ_CST)
|
||||
#define SPA_ATOMIC_XCHG(s,v) __atomic_exchange_n(&(s), (v), __ATOMIC_SEQ_CST)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue