summaryrefslogtreecommitdiff
path: root/dbus/dbus-memory.c
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2013-04-16 12:07:23 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-05-10 11:35:08 +0100
commit17a23d08b51cf21a2110047649a86445e99e2b3f (patch)
tree127ee33f09bab2955a07fd22e81781f0f79a2720 /dbus/dbus-memory.c
parent863c989bb631d7063597db30fe8add3233cca7fd (diff)
downloaddbus-17a23d08b51cf21a2110047649a86445e99e2b3f.tar.gz
dbus_threads_init_default, dbus_threads_init: be safe to call at any time
On Unix, we use a pthreads mutex, which can be allocated and initialized in global memory. On Windows, we use a CRITICAL_SECTION, together with a call to InitializeCriticalSection() from the constructor of a global static C++ object (thanks to Ralf Habacker for suggesting this approach). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Diffstat (limited to 'dbus/dbus-memory.c')
-rw-r--r--dbus/dbus-memory.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c
index a033b540..317e37ee 100644
--- a/dbus/dbus-memory.c
+++ b/dbus/dbus-memory.c
@@ -26,6 +26,7 @@
#include "dbus-internals.h"
#include "dbus-sysdeps.h"
#include "dbus-list.h"
+#include "dbus-threads.h"
#include <stdlib.h>
/**
@@ -890,7 +891,13 @@ dbus_shutdown (void)
dbus_free (c);
}
+ /* We wrap this in the thread-initialization lock because
+ * dbus_threads_init() uses the current generation to tell whether
+ * we're initialized, so we need to make sure that un-initializing
+ * propagates into all threads. */
+ _dbus_threads_lock_platform_specific ();
_dbus_current_generation += 1;
+ _dbus_threads_unlock_platform_specific ();
}
/** @} */ /** End of public API docs block */