[pulseaudio-discuss] pa_once can run twice?

David Henningsson david.henningsson at canonical.com
Fri Apr 20 07:44:15 PDT 2012


While researching a bug I came across something that might be a bug in 
the pa_once logic, but this stuff is tricky, so I might also be missing 
something.

Imagine this:

  * Thread 1 runs pa_once_begin, succeeds and starts running the payload 
(i e the code that should only run once).
  * Thread 2 starts running pa_once_begin, but only the first row. We're 
now right *before* pa_atomic_inc(&control->ref) but *after* 
pa_atomic_load(&control->done).
  * Thread 1 finishes the payload, runs pa_once_done which sets 
control->done and frees the mutex.
  * Thread 2 continues, pa_once_begin succeeds and the payload is now 
run a second time!


-- 
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic


More information about the pulseaudio-discuss mailing list