[libsoup] soup-message-io: only retry on I/O error if the connection has been used



commit 2442fc7785487b12d1d674bb04c7f889b6d3b8ca
Author: Dan Winship <danw gnome org>
Date:   Sat May 22 16:42:01 2010 -0400

    soup-message-io: only retry on I/O error if the connection has been used
    
    An I/O failure on a previously-used connection may indicate that the
    server timed out the connection; an I/O error on a fresh connection
    should not. Fixes infinite retries in certain edge cases.
    
    Part of https://bugzilla.gnome.org/show_bug.cgi?id=615535

 libsoup/soup-connection.c |   11 ++++++++++-
 libsoup/soup-connection.h |    2 ++
 libsoup/soup-message-io.c |    1 +
 3 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index 33e8024..d1cbfca 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -360,7 +360,6 @@ set_current_request (SoupConnection *conn, SoupMessage *req)
 	g_object_freeze_notify (G_OBJECT (conn));
 
 	stop_idle_timer (priv);
-	priv->unused_timeout = 0;
 
 	soup_message_set_io_status (req, SOUP_MESSAGE_IO_STATUS_RUNNING);
 	priv->cur_req = req;
@@ -382,6 +381,8 @@ clear_current_request (SoupConnection *conn)
 
 	g_object_freeze_notify (G_OBJECT (conn));
 
+	priv->unused_timeout = 0;
+
 	if (priv->state == SOUP_CONNECTION_IN_USE) {
 		/* We don't use soup_connection_set_state here since
 		 * it may call clear_current_request()...
@@ -682,6 +683,14 @@ soup_connection_set_state (SoupConnection *conn, SoupConnectionState state)
 	g_object_notify (G_OBJECT (conn), "state");
 }
 
+gboolean
+soup_connection_get_ever_used (SoupConnection *conn)
+{
+	g_return_val_if_fail (SOUP_IS_CONNECTION (conn), FALSE);
+
+	return SOUP_CONNECTION_GET_PRIVATE (conn)->unused_timeout == 0;
+}
+
 /**
  * soup_connection_send_request:
  * @conn: a #SoupConnection
diff --git a/libsoup/soup-connection.h b/libsoup/soup-connection.h
index f2ec40c..17b9f7b 100644
--- a/libsoup/soup-connection.h
+++ b/libsoup/soup-connection.h
@@ -70,6 +70,8 @@ SoupConnectionState soup_connection_get_state  (SoupConnection   *conn);
 void                soup_connection_set_state  (SoupConnection   *conn,
 						SoupConnectionState state);
 
+gboolean        soup_connection_get_ever_used  (SoupConnection   *conn);
+
 void            soup_connection_send_request   (SoupConnection   *conn,
 						SoupMessage      *req);
 
diff --git a/libsoup/soup-message-io.c b/libsoup/soup-message-io.c
index fc0e14d..02f2e45 100644
--- a/libsoup/soup-message-io.c
+++ b/libsoup/soup-message-io.c
@@ -200,6 +200,7 @@ io_error (SoupSocket *sock, SoupMessage *msg, GError *error)
 	} else if (io->mode == SOUP_MESSAGE_IO_CLIENT &&
 		   io->read_state <= SOUP_MESSAGE_IO_STATE_HEADERS &&
 		   io->read_meta_buf->len == 0 &&
+		   soup_connection_get_ever_used (io->conn) &&
 		   !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_TIMED_OUT) &&
 		   request_is_idempotent (msg)) {
 		/* Connection got closed, but we can safely try again */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]