[libsoup] SoupSession: when freeing an "unused" host, make sure it's still unused



commit 97db5d9cdea8fd4d8dca15e5d833c81bdf4dd40a
Author: Dan Winship <danw gnome org>
Date:   Sun Sep 9 10:19:00 2012 -0400

    SoupSession: when freeing an "unused" host, make sure it's still unused
    
    In a multithreaded session, it's possible that a new connection will
    be opened on a host while free_unused_host() is waiting to get
    conn_lock. So check for that before freeing it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=682923

 libsoup/soup-session.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index 54f1a2d..d0a0e21 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -1124,6 +1124,15 @@ free_unused_host (gpointer user_data)
 	SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (host->session);
 
 	g_mutex_lock (&priv->conn_lock);
+
+	/* In a multithreaded session, a connection might have been
+	 * added while we were waiting for conn_lock.
+	 */
+	if (host->connections) {
+		g_mutex_unlock (&priv->conn_lock);
+		return FALSE;
+	}
+
 	/* This will free the host in addition to removing it from the
 	 * hash table
 	 */



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