about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJosh Rickmar <jrick@devio.us>2013-05-14 12:04:34 -0400
committerJosh Rickmar <jrick@devio.us>2013-05-14 12:04:34 -0400
commita99ef02ba9242d6923e0b7a5cd204f8da3d78641 (patch)
treee47f3eaf09d3757f695703e87c80ed8a55de8713
parent33e11b2d4e49691eead713c7488d12d4e9633729 (diff)
downloadxombrero-a99ef02ba9242d6923e0b7a5cd204f8da3d78641.tar.gz
Remove threading
Now that the cert sideband thread is gone, threading can be removed.
Making GTK calls across multiple threads is also deprecated in newer
GTK versions and is severly broken on Windows, so there's no point in
keeping this around.
-rw-r--r--Makefile1
-rw-r--r--dragonfly/Makefile6
-rw-r--r--freebsd/Makefile6
-rw-r--r--linux/Makefile2
-rw-r--r--netbsd/Makefile7
-rw-r--r--osx/Makefile2
-rw-r--r--xombrero.c148
-rw-r--r--xombrero.h24
8 files changed, 15 insertions, 181 deletions
diff --git a/Makefile b/Makefile
index 57584b9..2260fba 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,6 @@ LIBS+= webkitgtk-3.0
 .endif
 LIBS+= libsoup-2.4
 LIBS+= gnutls
-LIBS+= gthread-2.0
 GTK_CFLAGS!= pkg-config --cflags $(LIBS)
 GTK_LDFLAGS!= pkg-config --libs $(LIBS)
 CFLAGS+= $(GTK_CFLAGS)
diff --git a/dragonfly/Makefile b/dragonfly/Makefile
index f438f1f..f0b8a32 100644
--- a/dragonfly/Makefile
+++ b/dragonfly/Makefile
@@ -4,13 +4,13 @@ LIBS= gtk+-2.0 webkit-1.0
 .else
 LIBS= gtk+-3.0 webkitgtk-3.0
 .endif
-LIBS+= libsoup-2.4 gnutls gthread-2.0
+LIBS+= libsoup-2.4 gnutls
 
 LDADD= -lutil -lgcrypt -lX11
 GTK_CFLAGS!= pkg-config --cflags $(LIBS)
 GTK_LDFLAGS!= pkg-config --libs $(LIBS)
-CFLAGS+= $(GTK_CFLAGS) -O2 -Wall -pthread -I. -I..
-LDFLAGS+= $(GTK_LDFLAGS) -pthread
+CFLAGS+= $(GTK_CFLAGS) -O2 -Wall -I. -I..
+LDFLAGS+= $(GTK_LDFLAGS)
 
 PREFIX?= /usr/local
 BINDIR?= $(PREFIX)/bin
diff --git a/freebsd/Makefile b/freebsd/Makefile
index fb1ccf7..b057202 100644
--- a/freebsd/Makefile
+++ b/freebsd/Makefile
@@ -4,13 +4,13 @@ LIBS= gtk+-2.0 webkit-1.0
 .else
 LIBS= gtk+-3.0 webkitgtk-3.0
 .endif
-LIBS+= libsoup-2.4 gnutls gthread-2.0
+LIBS+= libsoup-2.4 gnutls
 
 LDADD= -lutil -lgcrypt
 GTK_CFLAGS!= pkg-config --cflags $(LIBS)
 GTK_LDFLAGS!= pkg-config --libs $(LIBS)
-CFLAGS+= $(GTK_CFLAGS) -O2 -Wall -pthread -I. -I..
-LDFLAGS+= $(GTK_LDFLAGS) -pthread
+CFLAGS+= $(GTK_CFLAGS) -O2 -Wall -I. -I..
+LDFLAGS+= $(GTK_LDFLAGS)
 
 PREFIX?= /usr/local
 BINDIR?= $(PREFIX)/bin
diff --git a/linux/Makefile b/linux/Makefile
index 0e19d2a..0cc96cc 100644
--- a/linux/Makefile
+++ b/linux/Makefile
@@ -15,7 +15,7 @@ else
 LIBS+= gtk+-3.0 webkitgtk-3.0
 CFLAGS+=-I/usr/include/gtk-3.0
 endif
-LIBS+= libsoup-2.4 gthread-2.0 gnutls libbsd
+LIBS+= libsoup-2.4 gnutls libbsd
 
 CFLAGS+= -O2 -Wall -ggdb3 -D_GNU_SOURCE -I. -I.. $(shell pkg-config --cflags $(LIBS)) $(JS_CF)
 LDADD+= $(shell pkg-config --libs $(LIBS)) $(JS_LD) -ldl -lgcrypt -lX11
diff --git a/netbsd/Makefile b/netbsd/Makefile
index 7118caa..3939ddf 100644
--- a/netbsd/Makefile
+++ b/netbsd/Makefile
@@ -4,13 +4,13 @@ LIBS= gtk+-2.0 webkit-1.0
 .else
 LIBS= gtk+-3.0 webkitgtk-3.0
 .endif
-LIBS+= libsoup-2.4 gnutls gthread-2.0
+LIBS+= libsoup-2.4 gnutls
 
 LDADD= -lutil -lgcrypt -lX11
 GTK_CFLAGS!= pkg-config --cflags $(LIBS)
 GTK_LDFLAGS!= pkg-config --libs $(LIBS)
-CFLAGS+= $(GTK_CFLAGS) -O2 -Wall -pthread -I. -I..
-LDFLAGS+= $(GTK_LDFLAGS) -pthread
+CFLAGS+= $(GTK_CFLAGS) -O2 -Wall -I. -I..
+LDFLAGS+= $(GTK_LDFLAGS)
 
 PREFIX?= /usr/local
 BINDIR?= $(PREFIX)/bin
@@ -115,7 +115,6 @@ LIBS+= webkitgtk-3.0
 .endif
 LIBS+= libsoup-2.4
 LIBS+= gnutls
-LIBS+= gthread-2.0
 GTK_CFLAGS!= pkg-config --cflags $(LIBS)
 GTK_LDFLAGS!= pkg-config --libs $(LIBS)
 CFLAGS+= $(GTK_CFLAGS)
diff --git a/osx/Makefile b/osx/Makefile
index eaa9bfe..184d34a 100644
--- a/osx/Makefile
+++ b/osx/Makefile
@@ -1,6 +1,6 @@
 LIBS= glib-2.0
 LIBS+= gtk+-2.0 webkit-1.0
-LIBS+= libsoup-2.4 gthread-2.0 gnutls
+LIBS+= libsoup-2.4 gnutls
 
 CFLAGS+= -O2 -Wall -D_GNU_SOURCE -I. -I.. $(shell pkg-config --cflags $(LIBS)) $(JS_CF)
 LDADD+= $(shell pkg-config --libs $(LIBS)) $(JS_LD) -ldl -lgcrypt -lX11
diff --git a/xombrero.c b/xombrero.c
index 5800d23..b714ad4 100644
--- a/xombrero.c
+++ b/xombrero.c
@@ -48,10 +48,6 @@ uint32_t		swm_debug = 0
 			    ;
 #endif
 
-#ifdef USE_THREADS
-GCRY_THREAD_OPTION_PTHREAD_IMPL;
-#endif
-
 char		*icons[] = {
 	"xombreroicon16.png",
 	"xombreroicon32.png",
@@ -1109,21 +1105,6 @@ run_script(struct tab *t, char *s)
 	return (0);
 }
 
-int
-run_script_locked(struct tab *t, char *s)
-{
-	int		rv;
-#ifdef USE_THREADS
-	gdk_threads_enter();
-#endif
-	rv = run_script(t, s);
-#ifdef USE_THREADS
-	GDK_FLUSH();
-	gdk_threads_leave();
-#endif
-	return (rv);
-}
-
 void
 enable_hints(struct tab *t)
 {
@@ -1883,23 +1864,6 @@ done:
 	return (0);
 }
 
-/*
- * args must be allocated dynamically as the thread that added this function
- * to the idle loop no longer exists
- */
-gboolean
-warn_cert_cache_differs_idle(struct karg *args)
-{
-	if (args == NULL) {
-		show_oops(NULL, "%s: invalid parameters", __func__);
-		/* return 0 to not re-add function to the idle loop */
-		return (0);
-	}
-	xtp_page_sv((struct tab *)args->ptr, args);
-	g_free(args);
-	return (0);
-}
-
 /* Checks whether the remote cert is identical to the local saved
  * cert.  Returns CERT_LOCAL if unchanged, CERT_UNTRUSTED if local
  * cert does not exist, and CERT_BAD if different. 
@@ -1965,7 +1929,6 @@ check_cert_changes(struct tab *t, GTlsCertificate *cert, const char *file, const
 	SoupURI			*soupuri = NULL;
 	struct karg		args = {0};
 	struct wl_entry		*w = NULL;
-	struct karg		*argsp;
 	char			*chain = NULL;
 	int			ret = 0;
 
@@ -1988,10 +1951,8 @@ check_cert_changes(struct tab *t, GTlsCertificate *cert, const char *file, const
 		if ((w = wl_find(soupuri->host, &svil)) != NULL)
 			break;
 		t->xtp_meaning = XT_XTP_TAB_MEANING_SV;
-		argsp = g_malloc0(sizeof(struct karg));
-		argsp->s = g_strdup((char *)uri);
-		argsp->ptr = (void *)t;
-		g_idle_add((GSourceFunc)warn_cert_cache_differs_idle, argsp);
+		args.s = g_strdup((char *)uri);
+		xtp_page_sv(t, &args);
 		break;
 	}
 
@@ -4057,10 +4018,6 @@ notify_load_status_cb(WebKitWebView* wview, GParamSpec* pspec, struct tab *t)
 		t->focus_wv = 1;
 
 		marks_clear(t);
-#ifdef USE_THREAD
-		/* kill color thread */
-		t->thread = NULL;
-#endif
 		break;
 
 	case WEBKIT_LOAD_COMMITTED:
@@ -4322,7 +4279,7 @@ nofile:
 	}
 
 	DNPRINTF(XT_D_JS, "%s: about to run script\n", __func__);
-	run_script_locked(t, js);
+	run_script(t, js);
 
 done:
 	if (su)
@@ -7187,10 +7144,6 @@ delete_tab(struct tab *t)
 	if (t == NULL)
 		return;
 
-	/*
-	 * no need to join thread here because it won't access t on completion
-	 */
-
 	TAILQ_REMOVE(&tabs, t, entry);
 	buffercmd_abort(t);
 
@@ -8221,81 +8174,6 @@ usage(void)
 	exit(0);
 }
 
-GStaticRecMutex		my_gdk_mtx = G_STATIC_REC_MUTEX_INIT;
-volatile int		mtx_depth;
-int			mtx_complain;
-
-/*
- * The linux flash plugin violates the gdk locking mechanism.
- * Work around the issue by using a recursive mutex with some match applied
- * to see if we hit a buggy condition.
- *
- * The following code is painful so just don't read it.  It really doesn't
- * make much sense but seems to work.
- */
-void
-mtx_lock(void)
-{
-#ifdef XT_DEBUG
-	char		*s = NULL;
-#endif
-
-	g_static_rec_mutex_lock(&my_gdk_mtx);
-	if (my_gdk_mtx.depth <= 0) {
-#ifdef XT_DEBUG
-		s = "lock <= 0";
-#endif
-		g_static_rec_mutex_lock(&my_gdk_mtx);
-		goto complain;
-	} else if (my_gdk_mtx.depth != 1) {
-#ifdef XT_DEBUG
-		s = "lock != 1";
-#endif
-		do {
-			g_static_rec_mutex_unlock(&my_gdk_mtx);
-		} while (my_gdk_mtx.depth > 1);
-		goto complain;
-	}
-	return;
-
-complain:
-	if (mtx_complain == 0) {
-		DNPRINTF(XT_D_MTX, "buggy mutex implementation detected(%s), "
-		    "work around implemented", s);
-		mtx_complain = 1;
-	}
-}
-
-void
-mtx_unlock(void)
-{
-#ifdef XT_DEBUG
-	char		*s = NULL;
-#endif
-
-	if (my_gdk_mtx.depth <= 0) {
-#ifdef XT_DEBUG
-		s = "unlock <= 0";
-#endif
-		goto complain;
-	} else if (my_gdk_mtx.depth != 1) {
-#ifdef XT_DEBUG
-		s = "unlock != 1";
-#endif
-		g_static_rec_mutex_unlock_full(&my_gdk_mtx);
-		goto complain;
-	}
-	g_static_rec_mutex_unlock(&my_gdk_mtx);
-	return;
-
-complain:
-	if (mtx_complain == 0) {
-		DNPRINTF(XT_D_MTX, "buggy mutex implementation detected(%s), "
-		    "work around implemented", s);
-		mtx_complain = 1;
-	}
-}
-
 #if GTK_CHECK_VERSION(3, 0, 0)
 void
 setup_css(void)
@@ -8360,20 +8238,6 @@ main(int argc, char **argv)
 		os_init();
 
 	/* prepare gtk */
-#ifdef USE_THREADS
-#if !defined __MINGW32__
-	/* http://web.archiveorange.com/archive/v/UsPjxkX5PsaXBIoOjqxf */
-	XInitThreads();
-#endif
-	/* http://developer.gnome.org/gdk/stable/gdk-Threads.html */
-	g_thread_init(NULL);
-	gdk_threads_set_lock_functions(mtx_lock, mtx_unlock);
-	gdk_threads_init();
-	gdk_threads_enter();
-
-	/* http://www.gnupg.org/documentation/manuals/gcrypt/Multi_002dThreading.html */
-	gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
-#endif
 	gtk_init(&argc, &argv);
 
 	gnutls_global_init();
@@ -8788,12 +8652,6 @@ main(int argc, char **argv)
 
 	gtk_main();
 
-#ifdef USE_THREADS
-	GDK_FLUSH();
-	gdk_threads_leave();
-	g_static_rec_mutex_unlock_full(&my_gdk_mtx); /* just in case */
-#endif
-
 	gnutls_global_deinit();
 
 	if (url_regex)
diff --git a/xombrero.h b/xombrero.h
index f1461a1..8e0e505 100644
--- a/xombrero.h
+++ b/xombrero.h
@@ -106,24 +106,6 @@ uint32_t	arc4random_uniform(uint32_t);
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
 
-/* comment if you don't want to use threads */
-#define USE_THREADS
-
-#ifdef USE_THREADS
-/* http://seclists.org/wireshark/2011/Jul/209 */
-#define _GCRYPT_IN_LIBGCRYPT 1
-#include <gcrypt.h>
-#include <pthread.h>
-
-/* #define USE_FLUSH */
-#ifdef USE_FLUSH
-#define GDK_FLUSH()	do { gdk_flush(); } while (0)
-#else
-#define GDK_FLUSH()
-#endif /* USE_FLUSH */
-
-#endif
-
 /* set if you don't want to use resource limits */
 #ifndef XT_RESOURCE_LIMITS_DISABLE
 #include <sys/resource.h>
@@ -186,7 +168,6 @@ THE SOFTWARE.
 #define XT_D_CUSTOM_URI		0x80000
 #define XT_D_CMD_ALIAS		0x100000
 #define XT_D_SEARCH		0x200000
-#define XT_D_MTX		0x400000
 extern uint32_t	swm_debug;
 #else
 #define DPRINTF(x...)
@@ -283,10 +264,7 @@ struct tab {
 	gchar			*tmp_uri;
 	int			popup; /* 1 if cmd_entry has popup visible */
 	int			download_requested;
-#ifdef USE_THREADS
-	/* https thread stuff */
-	GThread			*thread;
-#endif
+
 	/* hints */
 	int			script_init;
 	int			new_tab;