From de95161f56561fa710f3952c8080cfb69cd35ba1 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 20 Feb 2012 12:56:01 +0000 Subject: [PATCH 7/7] Remove _dbus_condvar_wake_all and both of its implementations Neither was used, and the Windows version could lead to live-locks. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=43744 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=44609 --- dbus/dbus-sysdeps-pthread.c | 6 ------ dbus/dbus-sysdeps-thread-win.c | 20 -------------------- dbus/dbus-threads-internal.h | 2 -- dbus/dbus-threads.c | 12 ------------ 4 files changed, 0 insertions(+), 40 deletions(-) diff --git a/dbus/dbus-sysdeps-pthread.c b/dbus/dbus-sysdeps-pthread.c index 9758934..c9ec9e5 100644 --- a/dbus/dbus-sysdeps-pthread.c +++ b/dbus/dbus-sysdeps-pthread.c @@ -262,12 +262,6 @@ _dbus_platform_condvar_wake_one (DBusCondVar *cond) PTHREAD_CHECK ("pthread_cond_signal", pthread_cond_signal (&cond->cond)); } -void -_dbus_platform_condvar_wake_all (DBusCondVar *cond) -{ - PTHREAD_CHECK ("pthread_cond_broadcast", pthread_cond_broadcast (&cond->cond)); -} - static void check_monotonic_clock (void) { diff --git a/dbus/dbus-sysdeps-thread-win.c b/dbus/dbus-sysdeps-thread-win.c index db48619..e30e7b8 100644 --- a/dbus/dbus-sysdeps-thread-win.c +++ b/dbus/dbus-sysdeps-thread-win.c @@ -256,26 +256,6 @@ _dbus_platform_condvar_wake_one (DBusCondVar *cond) LeaveCriticalSection (&cond->lock); } -void -_dbus_platform_condvar_wake_all (DBusCondVar *cond) -{ - EnterCriticalSection (&cond->lock); - - while (cond->list != NULL) - SetEvent (_dbus_list_pop_first (&cond->list)); - - if (cond->list != NULL) - { - /* Avoid live lock by pushing the waiter to the mutex lock - instruction, which is fair. If we don't do this, we could - acquire the condition variable again before the waiter has a - chance itself, leading to starvation. */ - Sleep (0); - } - - LeaveCriticalSection (&cond->lock); -} - dbus_bool_t _dbus_threads_init_platform_specific (void) { diff --git a/dbus/dbus-threads-internal.h b/dbus/dbus-threads-internal.h index 680a603..64e8bac 100644 --- a/dbus/dbus-threads-internal.h +++ b/dbus/dbus-threads-internal.h @@ -66,7 +66,6 @@ dbus_bool_t _dbus_condvar_wait_timeout (DBusCondVar *cond, DBusCMutex *mutex, int timeout_milliseconds); void _dbus_condvar_wake_one (DBusCondVar *cond); -void _dbus_condvar_wake_all (DBusCondVar *cond); void _dbus_condvar_new_at_location (DBusCondVar **location_p); void _dbus_condvar_free_at_location (DBusCondVar **location_p); @@ -90,7 +89,6 @@ dbus_bool_t _dbus_platform_condvar_wait_timeout (DBusCondVar *cond, DBusCMutex *mutex, int timeout_milliseconds); void _dbus_platform_condvar_wake_one (DBusCondVar *cond); -void _dbus_platform_condvar_wake_all (DBusCondVar *cond); DBUS_END_DECLS diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index df00783..bb1169d 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -343,18 +343,6 @@ _dbus_condvar_wake_one (DBusCondVar *cond) _dbus_platform_condvar_wake_one (cond); } -/** - * If there are threads waiting on the condition variable, wake - * up all of them. - * Does nothing if passed a #NULL pointer. - */ -void -_dbus_condvar_wake_all (DBusCondVar *cond) -{ - if (cond && thread_init_generation == _dbus_current_generation) - _dbus_platform_condvar_wake_all (cond); -} - static void shutdown_global_locks (void *data) { -- 1.7.9