diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-09-23 10:44:41 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-09-23 10:44:41 +0100 |
commit | 46a2ca574fdb0121d27b6d148bed354061adf1d4 (patch) | |
tree | 119c40ed34c8521257f752c5d2062466ab7546a1 | |
parent | ccd80ddabd71e49c51a2b384b313bf87dc79c35a (diff) | |
download | telepathy-salut-46a2ca574fdb0121d27b6d148bed354061adf1d4.tar.gz |
Initialize libdbus for thread-safety
libdbus is not thread-safe by default. This is a long-standing design
flaw (<https://bugs.freedesktop.org/show_bug.cgi?id=54972>).
We call into GIO, which calls into glib-networking, which can
(at least in recent versions) invoke libproxy in a thread. libproxy
apparently has a Network-Manager plugin, which uses libdbus in that
thread; meanwhile, we use libdbus in the main thread and everything
goes badly for us.
In libdbus < 1.7.4, libraries cannot safely initialize libdbus for
multi-threading, because that initialization is not itself
thread-safe (!); in particular, glib-networking cannot safely initialize
libdbus. So, we have to do it.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65296
[copied from Gabble commit 83bb468e -smcv]
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r-- | src/salut.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/salut.c b/src/salut.c index 8b7f2893..f61c29fe 100644 --- a/src/salut.c +++ b/src/salut.c @@ -1,5 +1,7 @@ #include "config.h" +#include <dbus/dbus.h> + #include <glib.h> #include <telepathy-glib/telepathy-glib.h> @@ -45,6 +47,9 @@ main (int argc, char **argv) gint ret; SalutPluginLoader *loader; + if (!dbus_threads_init_default ()) + g_error ("Unable to initialize libdbus thread-safety (out of memory?)"); + g_type_init (); salut_symbol_hacks (); |