[evolution-patches] 70563, crash downloading images




usual issue of gconf being called != main thread.  this should fix, although i was unable to reproduce the problem itself.

Index: mail/em-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-utils.c,v
retrieving revision 1.50.4.2
diff -u -p -r1.50.4.2 em-utils.c
--- mail/em-utils.c	16 Sep 2004 14:45:55 -0000	1.50.4.2
+++ mail/em-utils.c	18 Jan 2005 04:40:43 -0000
@@ -1317,47 +1317,63 @@ em_utils_adjustment_page(GtkAdjustment *
 
 /* ********************************************************************** */
 static char *emu_proxy_uri;
+static int emu_proxy_init = 0;
+static pthread_mutex_t emu_proxy_lock = PTHREAD_MUTEX_INITIALIZER;
 
 static void
-emu_set_proxy(GConfClient *client)
+emu_set_proxy(GConfClient *client, int needlock)
 {
-	char *server;
+	char *server, *uri = NULL;
 	int port;
 
-	if (!gconf_client_get_bool(client, "/system/http_proxy/use_http_proxy", NULL)) {
-		g_free(emu_proxy_uri);
-		emu_proxy_uri = NULL;
+	if (gconf_client_get_bool(client, "/system/http_proxy/use_http_proxy", NULL)) {
+		server = gconf_client_get_string(client, "/system/http_proxy/host", NULL);
+		port = gconf_client_get_int(client, "/system/http_proxy/port", NULL);
+
+		if (server && server[0]) {
+			if (gconf_client_get_bool(client, "/system/http_proxy/use_authentication", NULL)) {
+				char *user = gconf_client_get_string(client, "/system/http_proxy/authentication_user", NULL);
+				char *pass = gconf_client_get_string(client, "/system/http_proxy/authentication_password", NULL);
+
+				uri = g_strdup_printf("http://%s:%s %s:%d", user, pass, server, port);
+				g_free(user);
+				g_free(pass);
+			} else {
+				uri = g_strdup_printf("http://%s:%d";, server, port);
+			}
+		}
 
-		return;
+		g_free(server);
 	}
 
-	/* TODO: Should lock ... */
-
-	server = gconf_client_get_string(client, "/system/http_proxy/host", NULL);
-	port = gconf_client_get_int(client, "/system/http_proxy/port", NULL);
+	if (needlock)
+		pthread_mutex_lock(&emu_proxy_lock);
 
-	if (server && server[0]) {
-		g_free(emu_proxy_uri);
+	g_free(emu_proxy_uri);
+	emu_proxy_uri = uri;
 
-		if (gconf_client_get_bool(client, "/system/http_proxy/use_authentication", NULL)) {
-			char *user = gconf_client_get_string(client, "/system/http_proxy/authentication_user", NULL);
-			char *pass = gconf_client_get_string(client, "/system/http_proxy/authentication_password", NULL);
-
-			emu_proxy_uri = g_strdup_printf("http://%s:%s %s:%d", user, pass, server, port);
-			g_free(user);
-			g_free(pass);
-		} else {
-			emu_proxy_uri = g_strdup_printf("http://%s:%d";, server, port);
-		}
-	}
+	if (needlock)
+		pthread_mutex_unlock(&emu_proxy_lock);
 
-	g_free(server);
 }
 
 static void
 emu_proxy_changed(GConfClient *client, guint32 cnxn_id, GConfEntry *entry, gpointer user_data)
 {
-	emu_set_proxy(client);
+	emu_set_proxy(client, TRUE);
+}
+
+static void *
+emu_proxy_setup(void *data)
+{
+	GConfClient *client = gconf_client_get_default();
+
+	gconf_client_add_dir(client, "/system/http_proxy", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+	gconf_client_notify_add(client, "/system/http_proxy", emu_proxy_changed, NULL, NULL, NULL);
+	emu_set_proxy(client, FALSE);
+	g_object_unref(client);
+
+	return NULL;
 }
 
 /**
@@ -1370,19 +1386,20 @@ emu_proxy_changed(GConfClient *client, g
 char *
 em_utils_get_proxy_uri(void)
 {
-	static int init;
+	char *uri;
 
-	if (!init) {
-		GConfClient *client = gconf_client_get_default();
+	pthread_mutex_lock(&emu_proxy_lock);
 
-		gconf_client_add_dir(client, "/system/http_proxy", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
-		gconf_client_notify_add(client, "/system/http_proxy", emu_proxy_changed, NULL, NULL, NULL);
-		emu_set_proxy(client);
-		g_object_unref(client);
-		init = TRUE;
+	if (!emu_proxy_init) {
+		mail_call_main(MAIL_CALL_p_p, emu_proxy_setup, NULL);
+		emu_proxy_init = TRUE;
 	}
 
-	return g_strdup(emu_proxy_uri);
+	uri = g_strdup(emu_proxy_uri);
+
+	pthread_mutex_unlock(&emu_proxy_lock);
+
+	return uri;
 }
 
 /**
Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3444.2.32
diff -u -p -r1.3444.2.32 ChangeLog
--- mail/ChangeLog	2 Dec 2004 04:11:04 -0000	1.3444.2.32
+++ mail/ChangeLog	18 Jan 2005 04:40:47 -0000
@@ -1,3 +1,21 @@
+2005-01-18  Not Zed  <NotZed Ximian com>
+
+	* em-format-html.c (emfh_gethttp): kill old 'load http 0 now=0' debug.
+
+	** See bug #70563.
+
+	* em-utils.c (emu_set_proxy, emu_proxy_setup)
+	(em_utils_get_proxy_uri): make sure the init code is called from
+	main thread (gconf usage), and add locking for data consistency.
+
+2005-01-08  Not Zed  <NotZed Ximian com>
+
+	* mail-account-gui.c (save_service): dont skip the authtype
+	setting if we don't have a needsauth widget at all (i.e. the store
+	page).
+
+	* em-folder-tree.c (emft_get_folder_info__desc): fix broken cast.
+
 2004-12-01  Not Zed  <NotZed Ximian com>
 
 	** See bug #69851.
Index: mail/em-format-html.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-format-html.c,v
retrieving revision 1.63.4.4
diff -u -p -r1.63.4.4 em-format-html.c
--- mail/em-format-html.c	1 Dec 2004 03:41:21 -0000	1.63.4.4
+++ mail/em-format-html.c	18 Jan 2005 04:40:47 -0000
@@ -455,7 +455,6 @@ static void emfh_gethttp(struct _EMForma
 	if (instream == NULL) {
 		char *proxy;
 
-		printf(" load http %d now=%d\n", job->format->load_http, job->format->load_http_now);
 
 		if (!(job->format->load_http_now
 		      || job->format->load_http == MAIL_CONFIG_HTTP_ALWAYS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]