pidgin: 0dae030d: jabber: Only initialize SASL once, too.

darkrain42 at pidgin.im darkrain42 at pidgin.im
Tue Mar 9 20:06:16 EST 2010


-----------------------------------------------------------------
Revision: 0dae030d2a4fe9f7c20a0823661eed7a5f982c09
Ancestor: 96b27a20c7250b87761a8bd4f5540bf1fa32b6f4
Author: darkrain42 at pidgin.im
Date: 2010-03-09T20:53:11
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/0dae030d2a4fe9f7c20a0823661eed7a5f982c09

Modified files:
        libpurple/protocols/jabber/jabber.c
        libpurple/protocols/jabber/libxmpp.c

ChangeLog: 

jabber: Only initialize SASL once, too.

A lot of these have moved from plugin init to plugin load time.  There's not
much that happens between then, but this could in theory cause issues.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c	4859766feba728341bd645043f9f4a78c036353f
+++ libpurple/protocols/jabber/jabber.c	0c41074bb68bdc3f66800742937fc8af6cb9032a
@@ -3539,7 +3539,37 @@ jabber_do_init(void)
 	const gchar *type = "pc"; /* default client type, if unknown or
 								unspecified */
 	const gchar *ui_name = NULL;
+#ifdef HAVE_CYRUS_SASL
+	/* We really really only want to do this once per process */
+	static gboolean sasl_initialized = FALSE;
+#ifdef _WIN32
+	UINT old_error_mode;
+	gchar *sasldir;
+#endif
+	int ret;
+#endif
 
+	/* XXX - If any other plugin wants SASL this won't be good ... */
+#ifdef HAVE_CYRUS_SASL
+	if (!sasl_initialized) {
+		sasl_initialized = TRUE;
+#ifdef _WIN32
+		sasldir = g_build_filename(wpurple_install_dir(), "sasl2", NULL);
+		sasl_set_path(SASL_PATH_TYPE_PLUGIN, sasldir);
+		g_free(sasldir);
+		/* Suppress error popups for failing to load sasl plugins */
+		old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS);
+#endif
+		if ((ret = sasl_client_init(NULL)) != SASL_OK) {
+			purple_debug_error("xmpp", "Error (%d) initializing SASL.\n", ret);
+		}
+#ifdef _WIN32
+		/* Restore the original error mode */
+		SetErrorMode(old_error_mode);
+#endif
+	}
+#endif
+
 	jabber_cmds = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, cmds_free_func);
 
 	ui_type = ui_info ? g_hash_table_lookup(ui_info, "client_type") : NULL;
============================================================
--- libpurple/protocols/jabber/libxmpp.c	9bb1535722a66ce893ef5b1b455fa1980fb4f904
+++ libpurple/protocols/jabber/libxmpp.c	5de4de8560fba67a58389258ab49baf5e73e6fec
@@ -249,13 +249,6 @@ init_plugin(PurplePlugin *plugin)
 static void
 init_plugin(PurplePlugin *plugin)
 {
-#ifdef HAVE_CYRUS_SASL
-#ifdef _WIN32
-	UINT old_error_mode;
-	gchar *sasldir;
-#endif
-	int ret;
-#endif
 	PurpleAccountUserSplit *split;
 	PurpleAccountOption *option;
 
@@ -315,24 +308,6 @@ init_plugin(PurplePlugin *plugin)
 
 	purple_prefs_remove("/plugins/prpl/jabber");
 
-	/* XXX - If any other plugin wants SASL this won't be good ... */
-#ifdef HAVE_CYRUS_SASL
-#ifdef _WIN32
-	sasldir = g_build_filename(wpurple_install_dir(), "sasl2", NULL);
-	sasl_set_path(SASL_PATH_TYPE_PLUGIN, sasldir);
-	g_free(sasldir);
-	/* Suppress error popups for failing to load sasl plugins */
-	old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS);
-#endif
-	if ((ret = sasl_client_init(NULL)) != SASL_OK) {
-		purple_debug_error("xmpp", "Error (%d) initializing SASL.\n", ret);
-	}
-#ifdef _WIN32
-	/* Restore the original error mode */
-	SetErrorMode(old_error_mode);
-#endif
-#endif
-
 	purple_signal_connect(purple_get_core(), "uri-handler", plugin,
 		PURPLE_CALLBACK(xmpp_uri_handler), NULL);
 }


More information about the Commits mailing list