pidgin/pidgin

Parents 25a255f32eee
Children cd43092f4731
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.
--- a/libpurple/proxy.c Sat Jan 16 10:01:23 2016 -0500
+++ b/libpurple/proxy.c Mon Jan 18 00:18:07 2016 -0600
@@ -732,11 +732,19 @@
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 @@
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 @@
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;
}