diff options
author | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2009-12-06 12:20:53 +0530 |
---|---|---|
committer | Colin Guthrie <cguthrie@mandriva.org> | 2009-12-06 11:51:17 +0000 |
commit | 978d33b609969c3b9bbbd759e0f11aaf856c80cf (patch) | |
tree | d6bd80af1d5f617281e0c2053ba92df9e2b4040b /src/pulse/thread-mainloop.c | |
parent | f42022a7d3157a3f3346b49c749d2262abea34c4 (diff) |
Mark shared variables as volatile
'n_waiting' and 'n_waiting_for_accept' may be accessed from mulitple
threads, and thus need to be marked as volatile to suppres certain
compiler optimisations. All uses are protected by a mutex, so we don't
need to worry about cache issues (added documentation for this as well).
This addresses bug #738.
Diffstat (limited to 'src/pulse/thread-mainloop.c')
-rw-r--r-- | src/pulse/thread-mainloop.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pulse/thread-mainloop.c b/src/pulse/thread-mainloop.c index a2b98ce1..14ed9264 100644 --- a/src/pulse/thread-mainloop.c +++ b/src/pulse/thread-mainloop.c @@ -51,7 +51,7 @@ struct pa_threaded_mainloop { pa_mainloop *real_mainloop; - int n_waiting, n_waiting_for_accept; + volatile int n_waiting, n_waiting_for_accept; pa_thread* thread; pa_mutex* mutex; @@ -185,6 +185,7 @@ void pa_threaded_mainloop_unlock(pa_threaded_mainloop *m) { pa_mutex_unlock(m->mutex); } +/* Called with the lock taken */ void pa_threaded_mainloop_signal(pa_threaded_mainloop *m, int wait_for_accept) { pa_assert(m); @@ -198,6 +199,7 @@ void pa_threaded_mainloop_signal(pa_threaded_mainloop *m, int wait_for_accept) { } } +/* Called with the lock taken */ void pa_threaded_mainloop_wait(pa_threaded_mainloop *m) { pa_assert(m); @@ -212,6 +214,7 @@ void pa_threaded_mainloop_wait(pa_threaded_mainloop *m) { m->n_waiting --; } +/* Called with the lock taken */ void pa_threaded_mainloop_accept(pa_threaded_mainloop *m) { pa_assert(m); |