From 15f9ba201b856f27e9e160000cbc654b64957618 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Tue, 10 Jan 2012 03:38:21 +0100 Subject: [PATCH] Fix logic in condition variable fairness. --- dbus/dbus-sysdeps-thread-win.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/dbus/dbus-sysdeps-thread-win.c b/dbus/dbus-sysdeps-thread-win.c index e2972a3..c46b45a 100644 --- a/dbus/dbus-sysdeps-thread-win.c +++ b/dbus/dbus-sysdeps-thread-win.c @@ -233,12 +233,16 @@ _dbus_windows_condvar_wake_one (DBusCondVar *cond) static void _dbus_windows_condvar_wake_all (DBusCondVar *cond) { + int any; + EnterCriticalSection (&cond->lock); + any = (cond->list != NULL); + while (cond->list != NULL) SetEvent (_dbus_list_pop_first (&cond->list)); - if (cond->list != NULL) + if (any) { /* Avoid live lock by pushing the waiter to the mutex lock instruction, which is fair. If we don't do this, we could -- 1.7.4.1