From d67c7ce1cf1329aee98eec413b56d57715abf9b7 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Sun, 13 Nov 2011 15:02:34 -0500 Subject: [PATCH] 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 --- libsoup/soup-connection.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c index 3e7f0ee..15260e4 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 */ -- 2.7.4