/pidgin/main: 1e58ac9ee097: Don't have proxy code call callbacks...

Mike Ruprecht cmaiku at gmail.com
Sat Jan 23 14:06:34 EST 2016


Changeset: 1e58ac9ee097c163148124d522485e560423cfe3
Author:	 Mike Ruprecht <cmaiku at gmail.com>
Date:	 2016-01-18 00:18 -0600
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/1e58ac9ee097

Description:

Don't have proxy code call callbacks if connect data disposed

The raw socket implementation wouldn't call callbacks after the
connect data was disposed. Replicate this behavior with the Gio
implementation.

The GCancellable is only cancelled when disposing the connect
data, so if the return from the async function is that it was
cancelled, it's safe to assume that the connect data has been
disposed.

diffstat:

 libpurple/proxy.c |  52 +++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 37 insertions(+), 15 deletions(-)

diffs (76 lines):

diff --git a/libpurple/proxy.c b/libpurple/proxy.c
--- a/libpurple/proxy.c
+++ b/libpurple/proxy.c
@@ -732,11 +732,19 @@ connect_to_host_cb(GObject *source, GAsy
 	conn = g_socket_client_connect_to_host_finish(G_SOCKET_CLIENT(source),
 			res, &error);
 	if (conn == NULL) {
-		purple_debug_error("proxy",
-				"Unable to connect to destination host: %s\n",
-				error->message);
-		purple_proxy_connect_data_disconnect(connect_data,
-				"Unable to connect to destination host.\n");
+		/* Ignore cancelled error as that signifies connect_data has
+		 * been freed
+		 */
+		if (!g_error_matches(error, G_IO_ERROR,
+				G_IO_ERROR_CANCELLED)) {
+			purple_debug_error("proxy", "Unable to connect to "
+					"destination host: %s\n",
+					error->message);
+			purple_proxy_connect_data_disconnect(connect_data,
+					"Unable to connect to destination "
+					"host.\n");
+		}
+
 		g_clear_error(&error);
 		return;
 	}
@@ -817,11 +825,19 @@ socks5_proxy_connect_cb(GObject *source,
 	stream = g_proxy_connect_finish(G_PROXY(source), res, &error);
 
 	if (stream == NULL) {
-		purple_debug_error("proxy",
-				"Unable to connect to destination host: %s\n",
-				error->message);
-		purple_proxy_connect_data_disconnect(connect_data,
-				"Unable to connecto to destination host.\n");
+		/* Ignore cancelled error as that signifies connect_data has
+		 * been freed
+		 */
+		if (!g_error_matches(error, G_IO_ERROR,
+				G_IO_ERROR_CANCELLED)) {
+			purple_debug_error("proxy", "Unable to connect to "
+					"destination host: %s\n",
+					error->message);
+			purple_proxy_connect_data_disconnect(connect_data,
+					"Unable to connect to destination "
+					"host.\n");
+		}
+
 		g_clear_error(&error);
 		return;
 	}
@@ -869,11 +885,17 @@ socks5_connect_to_host_cb(GObject *sourc
 	conn = g_socket_client_connect_to_host_finish(G_SOCKET_CLIENT(source),
 			res, &error);
 	if (conn == NULL) {
-		purple_debug_error("proxy",
-				"Unable to connect to SOCKS5 host: %s\n",
-				error->message);
-		purple_proxy_connect_data_disconnect(connect_data,
-				"Unable to connect to SOCKS5 host.\n");
+		/* Ignore cancelled error as that signifies connect_data has
+		 * been freed
+		 */
+		if (!g_error_matches(error, G_IO_ERROR,
+				G_IO_ERROR_CANCELLED)) {
+			purple_debug_error("proxy", "Unable to connect to "
+					"SOCKS5 host: %s\n", error->message);
+			purple_proxy_connect_data_disconnect(connect_data,
+					"Unable to connect to SOCKS5 host.\n");
+		}
+
 		g_clear_error(&error);
 		return;
 	}



More information about the Commits mailing list