diff options
author | Mike Ruprecht <cmaiku@gmail.com> | 2016-01-18 00:18:07 -0600 |
---|---|---|
committer | Mike Ruprecht <cmaiku@gmail.com> | 2016-01-18 00:18:07 -0600 |
commit | 4573e10032639fbb68fbd96132655de09011f28d (patch) | |
tree | 9105683610e51f63d89341b1f1e7675c93ff22fc | |
parent | e67292fa61348252ada7030c98f9a45c05b99070 (diff) | |
download | pidgin-4573e10032639fbb68fbd96132655de09011f28d.tar.gz |
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.
-rw-r--r-- | libpurple/proxy.c | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/libpurple/proxy.c b/libpurple/proxy.c index 2bd1561fb0..da01bb4a51 100644 --- a/libpurple/proxy.c +++ b/libpurple/proxy.c @@ -732,11 +732,19 @@ connect_to_host_cb(GObject *source, GAsyncResult *res, gpointer user_data) 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, GAsyncResult *res, gpointer user_data) 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 *source, GAsyncResult *res, 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; } |