[PACRunner PATCH] Always require thread support

David Woodhouse dwmw2 at infradead.org
Sun Jan 2 18:09:15 PST 2011


We use threads unconditionally. Even if we don't have a JS plugin.

diff --git a/Makefile.am b/Makefile.am
index 65a1e49..d579212 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -48,8 +48,8 @@ src_pacrunner_SOURCES = $(gdbus_sources) $(builtin_sources) \
 			src/client.c src/manager.c src/proxy.c \
 			src/manual.c src/js.h src/js.c src/javascript.h
 
-src_pacrunner_LDADD = $(builtin_libadd) \
-				@GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
+src_pacrunner_LDADD = $(builtin_libadd) @GLIB_LIBS@ @GTHREAD_LIBS@ \
+				@DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
 src_pacrunner_LDFLAGS = -Wl,--export-dynamic
 
@@ -93,10 +93,10 @@ unit_test_mozjs_SOURCES = unit/test-mozjs.c src/pacrunner.h \
 			src/proxy.c src/manual.c src/download.c \
 				src/js.c plugins/mozjs.c
 
-unit_test_mozjs_LDADD = @MOZJS_LIBS@ @GLIB_LIBS@
+unit_test_mozjs_LDADD = @MOZJS_LIBS@ @GLIB_LIBS@ @GTHREAD_LIBS@
 endif
 
-AM_CFLAGS = @GLIB_CFLAGS@ @DBUS_CFLAGS@ @CAPNG_CFLAGS@ \
+AM_CFLAGS = @GLIB_CFLAGS@ @GTHREAD_LIBS@ @DBUS_CFLAGS@ @CAPNG_CFLAGS@ \
 					$(builtin_cflags) \
 					-DPACRUNNER_PLUGIN_BUILTIN \
 					-DPLUGINDIR=\""$(plugindir)"\"
diff --git a/configure.ac b/configure.ac
index f643b8d..12593c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,7 +60,7 @@ AC_ARG_ENABLE(pie, AC_HELP_STRING([--enable-pie],
 AC_ARG_ENABLE(mozjs, AC_HELP_STRING([--enable-mozjs],
 		[enable Mozilla Javascript plugin support]))
 if (test "${enable_mozjs}" = "yes"); then
-	PKG_CHECK_MODULES(MOZJS,  mozilla-js >= 1.9, enable_threads=yes,
+	PKG_CHECK_MODULES(MOZJS,  mozilla-js >= 1.9, dummy=yes,
 			AC_MSG_ERROR(Mozilla Javascript >= 1.9 is required))
 	AC_SUBST(MOZJS_CFLAGS)
 	AC_SUBST(MOZJS_LIBS)
@@ -71,15 +71,11 @@ AC_ARG_ENABLE(v8, AC_HELP_STRING([--enable-v8],
 		[enable V8 Javascript plugin support]))
 if (test "${enable_v8}" = "yes"); then
 	AC_CHECK_LIB(v8, _ZN2v82V810InitializeEv,
-		[enable_threads=yes V8_LIBS="-lv8 -lpthread" AC_SUBST(V8_LIBS)],
+		[V8_LIBS="-lv8 -lpthread" AC_SUBST(V8_LIBS)],
 		[AC_MSG_ERROR(Chrome v8 is required)], -lpthread)
 fi
 AM_CONDITIONAL(V8, test "${enable_v8}" = "yes")
 
-AC_ARG_ENABLE(threads,
-	AC_HELP_STRING([--enable-threads], [enable threading support]),
-			[enable_threads=${enableval}], [enable_threads="no"])
-
 PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes,
 				AC_MSG_ERROR(GLib >= 2.16 is required))
 AC_SUBST(GLIB_CFLAGS)
@@ -123,13 +119,10 @@ if (test "${enable_capng}" = "yes"); then
 	AC_DEFINE(HAVE_CAPNG, 1, [Define to 1 if you have capabilities library.])
 fi
 
-if (test "${enable_threads}" = "yes"); then
-	AC_DEFINE(NEED_THREADS, 1, [Define if threading support is required])
-	PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
-				AC_MSG_ERROR(GThread >= 2.16 is required))
-	GLIB_CFLAGS="$GLIB_CFLAGS $GTHREAD_CFLAGS"
-	GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS"
-fi
+PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.16, dummy=yes,
+			AC_MSG_ERROR(GThread >= 2.16 is required))
+AC_SUBST(GTHREAD_CFLAGS)
+AC_SUBST(GTHREAD_LIBS)
 
 AC_ARG_ENABLE(curl, AC_HELP_STRING([--enable-curl],
 		[enable CURL plugin support]), [enable_capng=${enableval}])
diff --git a/src/main.c b/src/main.c
index 6753df6..da98d0e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -107,10 +107,8 @@ int main(int argc, char *argv[])
 	capng_apply(CAPNG_SELECT_BOTH);
 #endif
 
-#ifdef NEED_THREADS
 	if (g_thread_supported() == FALSE)
 		g_thread_init(NULL);
-#endif
 
 	context = g_option_context_new(NULL);
 	g_option_context_add_main_entries(context, options, NULL);
@@ -140,12 +138,10 @@ int main(int argc, char *argv[])
 
 	main_loop = g_main_loop_new(NULL, FALSE);
 
-#ifdef NEED_THREADS
 	if (dbus_threads_init_default() == FALSE) {
 		fprintf(stderr, "Can't init usage of threads\n");
 		exit(1);
 	}
-#endif
 
 	dbus_error_init(&err);
 

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse at intel.com                              Intel Corporation




More information about the connman mailing list