Blob Blame History Raw
From ba5f2e307b2ee45f4cc166f6b488c7bc8559bfc7 Mon Sep 17 00:00:00 2001
From: Dan Winship <danw@gnome.org>
Date: Fri, 2 May 2014 15:37:38 -0400
Subject: [PATCH] soup-session: fix connection-closing behavior on abort

soup_session_abort()'s docs claim that it closes "all idle persistent
connections", but it was actually trying to close *all* connections,
including ones that were being actively used in other threads. Fix
that.

https://bugzilla.redhat.com/show_bug.cgi?id=1093314
---
 libsoup/soup-session.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index 6deff7e..cbefc64 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -2482,14 +2482,20 @@ soup_session_abort (SoupSession *session)
 
 	SOUP_SESSION_GET_CLASS (session)->flush_queue (session);
 
-	/* Close all connections */
+	/* Close all idle connections */
 	g_mutex_lock (&priv->conn_lock);
 	conns = NULL;
 	g_hash_table_iter_init (&iter, priv->conns);
 	while (g_hash_table_iter_next (&iter, &conn, &host)) {
-		conns = g_slist_prepend (conns, g_object_ref (conn));
-		g_hash_table_iter_remove (&iter);
-		drop_connection (session, host, conn);
+		SoupConnectionState state;
+
+		state = soup_connection_get_state (conn);
+		if (state == SOUP_CONNECTION_IDLE ||
+		    state == SOUP_CONNECTION_REMOTE_DISCONNECTED) {
+			conns = g_slist_prepend (conns, g_object_ref (conn));
+			g_hash_table_iter_remove (&iter);
+			drop_connection (session, host, conn);
+		}
 	}
 	g_mutex_unlock (&priv->conn_lock);
 
-- 
1.9.3