threaded-mainloop: loop around pa_cond_wait() invocation in pa_threaded_mainloop_signal()

This commit is contained in:
Lennart Poettering 2009-07-30 23:46:25 +02:00
parent f8873ab82b
commit 4f5e2b745e
2 changed files with 13 additions and 4 deletions

View file

@ -51,7 +51,7 @@
struct pa_threaded_mainloop {
pa_mainloop *real_mainloop;
int n_waiting;
int n_waiting, n_waiting_for_accept;
pa_thread* thread;
pa_mutex* mutex;
@ -190,8 +190,12 @@ void pa_threaded_mainloop_signal(pa_threaded_mainloop *m, int wait_for_accept) {
pa_cond_signal(m->cond, 1);
if (wait_for_accept && m->n_waiting > 0)
pa_cond_wait(m->accept_cond, m->mutex);
if (wait_for_accept) {
m->n_waiting_for_accept ++;
while (m->n_waiting_for_accept > 0)
pa_cond_wait(m->accept_cond, m->mutex);
}
}
void pa_threaded_mainloop_wait(pa_threaded_mainloop *m) {
@ -214,6 +218,9 @@ void pa_threaded_mainloop_accept(pa_threaded_mainloop *m) {
/* Make sure that this function is not called from the helper thread */
pa_assert(!m->thread || !pa_thread_is_running(m->thread) || !in_worker(m));
pa_assert(m->n_waiting_for_accept > 0);
m->n_waiting_for_accept --;
pa_cond_signal(m->accept_cond, 0);
}