summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2013-01-07 15:50:36 -0500
committerDan Winship <danw@gnome.org>2013-01-07 15:56:25 -0500
commitc2ce0f99c1551161fdf6e13a9f83bf8cb656b6d6 (patch)
tree6f7441883d05b917d43f35fa448c2c9cca67ba7a
parent0cb3c8293b37ade115118096298b002a7a9f7c9c (diff)
downloadlibsoup-c2ce0f99c1551161fdf6e13a9f83bf8cb656b6d6.tar.gz
libsoup-c2ce0f99c1551161fdf6e13a9f83bf8cb656b6d6.tar.bz2
libsoup-c2ce0f99c1551161fdf6e13a9f83bf8cb656b6d6.zip
Revert "SoupConnection: disconnect on failed connections/tunnels"
Disconnecting clears priv->sock, and in some cases, the caller may want to look at that after the failed connection. So switch this back to having the session do the disconnecting itself (which is simpler now due to various SoupSession rewrites), and remove one inconsistent case where the connection was disconnecting itself before. This reverts commit 21d707d66460233596a04f6dc99c945d2dbc3085.
-rw-r--r--libsoup/soup-connection.c22
-rw-r--r--libsoup/soup-session.c2
2 files changed, 5 insertions, 19 deletions
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index 21613946..a6ed5243 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -474,8 +474,6 @@ socket_connect_finished (SoupSocket *socket, guint status, gpointer user_data)
status = soup_status_proxify (status);
data->callback (data->conn, status, data->callback_data);
}
- if (!SOUP_STATUS_IS_SUCCESSFUL (status) && status != SOUP_STATUS_TRY_AGAIN)
- soup_connection_disconnect (data->conn);
g_object_unref (data->conn);
if (data->cancellable)
g_object_unref (data->cancellable);
@@ -641,6 +639,7 @@ soup_connection_connect_sync (SoupConnection *conn, GCancellable *cancellable)
SOUP_SOCKET_CLEAN_DISPOSE, TRUE,
NULL);
g_object_unref (remote_addr);
+
event_id = g_signal_connect (priv->socket, "event",
G_CALLBACK (proxy_socket_event), conn);
status = soup_socket_connect_sync (priv->socket, cancellable);
@@ -679,17 +678,9 @@ soup_connection_connect_sync (SoupConnection *conn, GCancellable *cancellable)
soup_connection_set_state (conn, SOUP_CONNECTION_IN_USE);
priv->unused_timeout = time (NULL) + SOUP_CONNECTION_UNUSED_TIMEOUT;
start_idle_timer (conn);
- } else if (status != SOUP_STATUS_TRY_AGAIN) {
- fail:
- if (priv->socket) {
- soup_socket_disconnect (priv->socket);
- g_object_unref (priv->socket);
- priv->socket = NULL;
- }
-
- soup_connection_disconnect (conn);
}
+ fail:
if (priv->socket && event_id)
g_signal_handler_disconnect (priv->socket, event_id);
@@ -721,10 +712,8 @@ soup_connection_start_ssl_sync (SoupConnection *conn,
if (!soup_socket_start_proxy_ssl (priv->socket,
priv->remote_uri->host,
- cancellable)) {
- soup_connection_disconnect (conn);
+ cancellable))
return SOUP_STATUS_SSL_FAILED;
- }
soup_connection_event (conn, G_SOCKET_CLIENT_TLS_HANDSHAKING, NULL);
status = soup_socket_handshake_sync (priv->socket, cancellable);
@@ -736,9 +725,6 @@ soup_connection_start_ssl_sync (SoupConnection *conn,
status = SOUP_STATUS_TRY_AGAIN;
}
- if (!SOUP_STATUS_IS_SUCCESSFUL (status) && status != SOUP_STATUS_TRY_AGAIN)
- soup_connection_disconnect (conn);
-
return status;
}
@@ -757,8 +743,6 @@ start_ssl_completed (SoupSocket *socket, guint status, gpointer user_data)
}
data->callback (data->conn, status, data->callback_data);
- if (!SOUP_STATUS_IS_SUCCESSFUL (status) && status != SOUP_STATUS_TRY_AGAIN)
- soup_connection_disconnect (data->conn);
g_object_unref (data->conn);
g_slice_free (SoupConnectionAsyncConnectData, data);
}
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index 1132479d..e37a71d5 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -1513,6 +1513,7 @@ tunnel_complete (SoupConnection *conn, guint status, gpointer user_data)
soup_message_set_https_status (item->msg, item->conn);
if (!SOUP_STATUS_IS_SUCCESSFUL (status)) {
+ soup_connection_disconnect (conn);
soup_session_set_item_connection (session, item, NULL);
soup_session_set_item_status (session, item, status);
}
@@ -1597,6 +1598,7 @@ got_connection (SoupConnection *conn, guint status, gpointer user_data)
SoupSession *session = item->session;
if (status != SOUP_STATUS_OK) {
+ soup_connection_disconnect (conn);
if (item->state == SOUP_MESSAGE_CONNECTING) {
soup_session_set_item_status (session, item, status);
soup_session_set_item_connection (session, item, NULL);