summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2011-11-13 15:02:34 -0500
committerDan Winship <danw@gnome.org>2011-11-13 15:06:17 -0500
commitd67c7ce1cf1329aee98eec413b56d57715abf9b7 (patch)
treebedba0689919163915a5e7d1061fa5f3695afa4b
parent2a03bc205b096bb9ecff1ea9dacd155cb16da1fb (diff)
downloadlibsoup-d67c7ce1cf1329aee98eec413b56d57715abf9b7.tar.gz
Fix handling of connections that time out while IN_USE
To avoid looping, we only resend a request on unexpected-connection-close if it was sent on a connection that has previously been succesfully used. But we were only setting the "successfully" used flag after a message *completed*, so if a message just got restarted, and the connection got closed before the second sending, then the connection was seen as having never been used, and so the message wouldn't get re-sent. Fix this by marking the connection as having been used if a message it is sending gets restarted. https://bugzilla.gnome.org/show_bug.cgi?id=660057
-rw-r--r--libsoup/soup-connection.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index 3e7f0eed..15260e42 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -407,6 +407,15 @@ stop_idle_timer (SoupConnectionPrivate *priv)
}
static void
+current_item_restarted (SoupMessage *msg, gpointer user_data)
+{
+ SoupConnection *conn = user_data;
+ SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (conn);
+
+ priv->unused_timeout = 0;
+}
+
+static void
set_current_item (SoupConnection *conn, SoupMessageQueueItem *item)
{
SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (conn);
@@ -421,6 +430,9 @@ set_current_item (SoupConnection *conn, SoupMessageQueueItem *item)
priv->cur_item = item;
g_object_notify (G_OBJECT (conn), "message");
+ g_signal_connect (item->msg, "restarted",
+ G_CALLBACK (current_item_restarted), conn);
+
if (priv->state == SOUP_CONNECTION_IDLE ||
item->msg->method != SOUP_METHOD_CONNECT)
soup_connection_set_state (conn, SOUP_CONNECTION_IN_USE);
@@ -445,6 +457,8 @@ clear_current_item (SoupConnection *conn)
priv->cur_item = NULL;
g_object_notify (G_OBJECT (conn), "message");
+ g_signal_handlers_disconnect_by_func (item->msg, G_CALLBACK (current_item_restarted), conn);
+
if (item->msg->method == SOUP_METHOD_CONNECT &&
SOUP_STATUS_IS_SUCCESSFUL (item->msg->status_code)) {
/* We're now effectively no longer proxying */