summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2018-03-26 15:34:50 +0200
committerMilan Crha <mcrha@redhat.com>2018-03-26 15:34:50 +0200
commitd28962ff4d5020a9b906f5492acad69b533be2d1 (patch)
tree03b181f022afa715230e4d299c3d4cb3a9aee039
parentf7760e8343b8f9ef0ae363c2944c2b1426021687 (diff)
downloadlibsoup-d28962ff4d5020a9b906f5492acad69b533be2d1.tar.gz
Crash under soup_socket_new()
https://bugzilla.gnome.org/show_bug.cgi?id=762138
-rw-r--r--libsoup/soup-session.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index a8996a1c..ae340b9c 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -127,10 +127,11 @@ typedef struct {
/* Must hold the conn_lock before potentially creating a new
* SoupSessionHost, adding/removing a connection,
- * disconnecting a connection, or moving a connection from
- * IDLE to IN_USE. Must not emit signals or destroy objects
- * while holding it. conn_cond is signaled when it may be
- * possible for a previously-blocked message to continue.
+ * disconnecting a connection, moving a connection from
+ * IDLE to IN_USE, or when updating socket properties.
+ * Must not emit signals or destroy objects while holding it.
+ * The conn_cond is signaled when it may be possible for
+ * a previously-blocked message to continue.
*/
GMutex conn_lock;
GCond conn_cond;
@@ -355,6 +356,7 @@ soup_session_finalize (GObject *object)
G_OBJECT_CLASS (soup_session_parent_class)->finalize (object);
}
+/* requires conn_lock */
static void
ensure_socket_props (SoupSession *session)
{
@@ -770,11 +772,13 @@ soup_session_set_property (GObject *object, guint prop_id,
break;
}
+ g_mutex_lock (&priv->conn_lock);
if (priv->socket_props && socket_props_changed) {
soup_socket_properties_unref (priv->socket_props);
priv->socket_props = NULL;
ensure_socket_props (session);
}
+ g_mutex_unlock (&priv->conn_lock);
}
static void
@@ -794,7 +798,9 @@ soup_session_get_property (GObject *object, guint prop_id,
g_value_set_boxed (value, priv->proxy_uri);
break;
case PROP_PROXY_RESOLVER:
+ g_mutex_lock (&priv->conn_lock);
ensure_socket_props (session);
+ g_mutex_unlock (&priv->conn_lock);
g_value_set_object (value, priv->proxy_resolver);
break;
case PROP_MAX_CONNS:
@@ -815,12 +821,16 @@ soup_session_get_property (GObject *object, guint prop_id,
break;
case PROP_SSL_USE_SYSTEM_CA_FILE:
tlsdb = g_tls_backend_get_default_database (g_tls_backend_get_default ());
+ g_mutex_lock (&priv->conn_lock);
ensure_socket_props (session);
+ g_mutex_unlock (&priv->conn_lock);
g_value_set_boolean (value, priv->tlsdb == tlsdb);
g_clear_object (&tlsdb);
break;
case PROP_TLS_DATABASE:
+ g_mutex_lock (&priv->conn_lock);
ensure_socket_props (session);
+ g_mutex_unlock (&priv->conn_lock);
g_value_set_object (value, priv->tlsdb);
break;
case PROP_TLS_INTERACTION: