From cef11442f69e9a649731f3b2a12b655996da265b Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 23 Jun 2003 02:12:19 +0000 Subject: 2003-06-22 Havoc Pennington * mono/Connection.cs: add more bindings * dbus/dbus-threads.c (dbus_threads_init): allow calling this more than once. --- dbus/dbus-threads.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'dbus') diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index 5f953d82..b604a397 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -279,8 +279,10 @@ init_global_locks (void) * in efficiency. Note that this function must be called * BEFORE using any other D-BUS functions. * - * @todo right now this function can only be called once, - * maybe we should instead silently ignore multiple calls. + * This function may be called more than once, as long + * as you pass in the same functions each time. If it's + * called multiple times with different functions, then + * a warning is printed, because someone is confused. * * @param functions functions for using threads * @returns #TRUE on success, #FALSE if no memory @@ -325,8 +327,20 @@ dbus_threads_init (const DBusThreadFunctions *functions) if (thread_functions.mask != 0) { - _dbus_warn ("dbus_threads_init() may only be called one time\n"); - return FALSE; + /* Silently allow multiple init if the functions are the same ones. + * Well, we only bother checking two of them, just out of laziness. + */ + if (thread_functions.mask == functions->mask && + thread_functions.mutex_new == functions->mutex_new && + thread_functions.condvar_new == functions->condvar_new) + { + return TRUE; + } + else + { + _dbus_warn ("dbus_threads_init() called twice with two different sets of functions\n"); + return FALSE; + } } thread_functions.mutex_new = functions->mutex_new; -- cgit