Diff between 7c20375b77548ad5e7818c113bc3d3b465691574 and c79d67ac1f7d91759a77f7a7397701d178e0b4a9

Changed Files

File Additions Deletions Status
obexd/src/plugin.c +12 -1 modified

Full Patch

diff --git a/obexd/src/plugin.c b/obexd/src/plugin.c
index 13dda96..b6320d4 100644
--- a/obexd/src/plugin.c
+++ b/obexd/src/plugin.c
@@ -35,6 +35,17 @@
 #include "plugin.h"
 #include "logging.h"
 
+/*
+ * Plugins that are using libraries with threads and their own mainloop
+ * will crash on exit. This is a bug inside these libraries, but there is
+ * nothing much that can be done about it. One bad example is libebook.
+ */
+#ifdef NEED_THREADS
+#define PLUGINFLAG (RTLD_NOW | RTLD_NODELETE)
+#else
+#define PLUGINFLAG (RTLD_NOW)
+#endif
+
 static GSList *plugins = NULL;
 
 struct obex_plugin {
@@ -99,7 +110,7 @@ gboolean plugin_init(void)
 			continue;
 		}
 
-		handle = dlopen(filename, RTLD_NOW);
+		handle = dlopen(filename, PLUGINFLAG);
 		if (handle == NULL) {
 			error("Can't load plugin %s: %s", filename,
 								dlerror());