This commit is contained in:
Gwyn Ciesla 2023-09-15 11:00:09 -05:00
parent 7256cdaa42
commit 4f98f9a838
5 changed files with 3 additions and 122 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@
/libsoup-3.4.0.tar.xz /libsoup-3.4.0.tar.xz
/libsoup-3.4.1.tar.xz /libsoup-3.4.1.tar.xz
/libsoup-3.4.2.tar.xz /libsoup-3.4.2.tar.xz
/libsoup-3.4.3.tar.xz

View File

@ -1,79 +0,0 @@
From 31d415ca44349fe8c4d2e0b2fb56f84501ec9524 Mon Sep 17 00:00:00 2001
From: Michael Catanzaro <mcatanzaro@redhat.com>
Date: Mon, 21 Aug 2023 12:54:53 -0500
Subject: [PATCH 1/2] connection-manager: don't crash if connection outlives
its manager
I have no clue whether SoupConnections are expected to outlive
SoupConnectionManager or not, but it's happening, and it doesn't seem too
surprising; after all, SoupConnection is a GObject, and things can keep
references to it. Guard against this by disconnecting from the signals
of each SoupConnection when destroying the SoupConnectionManager.
Probably fixes #361
---
libsoup/soup-connection-manager.c | 34 +++++++++++++++++++++----------
1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/libsoup/soup-connection-manager.c b/libsoup/soup-connection-manager.c
index e6f7caa7..5c4ec741 100644
--- a/libsoup/soup-connection-manager.c
+++ b/libsoup/soup-connection-manager.c
@@ -206,6 +206,26 @@ soup_connection_manager_get_or_create_host_for_item (SoupConnectionManager *mana
return host;
}
+static void
+soup_connection_manager_drop_connection (SoupConnectionManager *manager,
+ SoupConnection *conn)
+{
+ g_signal_handlers_disconnect_by_data (conn, manager);
+ manager->num_conns--;
+ g_object_unref (conn);
+
+ g_cond_broadcast (&manager->cond);
+}
+
+static void
+remove_connection (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ SoupConnectionManager *manager = user_data;
+ soup_connection_manager_drop_connection (manager, key);
+}
+
SoupConnectionManager *
soup_connection_manager_new (SoupSession *session,
guint max_conns,
@@ -235,6 +255,9 @@ soup_connection_manager_new (SoupSession *session,
void
soup_connection_manager_free (SoupConnectionManager *manager)
{
+ g_hash_table_foreach (manager->conns, remove_connection, manager);
+ g_assert (manager->num_conns == 0);
+
g_clear_object (&manager->remote_connectable);
g_hash_table_destroy (manager->http_hosts);
g_hash_table_destroy (manager->https_hosts);
@@ -293,17 +316,6 @@ soup_connection_manager_get_num_conns (SoupConnectionManager *manager)
return manager->num_conns;
}
-static void
-soup_connection_manager_drop_connection (SoupConnectionManager *manager,
- SoupConnection *conn)
-{
- g_signal_handlers_disconnect_by_data (conn, manager);
- manager->num_conns--;
- g_object_unref (conn);
-
- g_cond_broadcast (&manager->cond);
-}
-
static void
soup_connection_list_disconnect_all (GList *conns)
{
--
2.41.0

View File

@ -1,34 +0,0 @@
From c978ab757ab62b295e65936858758fdf7e67b6bc Mon Sep 17 00:00:00 2001
From: Michael Catanzaro <mcatanzaro@redhat.com>
Date: Mon, 21 Aug 2023 12:56:55 -0500
Subject: [PATCH 2/2] connection-auth: don't crash if connection outlives the
auth
Currently we crash if the SoupConnection lives longer than the
SoupConnectionAuth. I'm unsure whether this is intended to happen, but
since it does happen, we should probably disconnect from the
SoupConnection's signal rather than crash when it does.
Probably fixes #348
---
libsoup/auth/soup-connection-auth.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libsoup/auth/soup-connection-auth.c b/libsoup/auth/soup-connection-auth.c
index 2d9514f9..34d40d12 100644
--- a/libsoup/auth/soup-connection-auth.c
+++ b/libsoup/auth/soup-connection-auth.c
@@ -113,8 +113,8 @@ soup_connection_auth_get_connection_state_for_message (SoupConnectionAuth *auth,
g_hash_table_insert (priv->conns, conn, state);
g_mutex_unlock (&priv->lock);
if (conn) {
- g_signal_connect (conn, "disconnected",
- G_CALLBACK (connection_disconnected), auth);
+ g_signal_connect_object (conn, "disconnected",
+ G_CALLBACK (connection_disconnected), auth, 0);
}
} else {
g_mutex_unlock (&priv->lock);
--
2.41.0

View File

@ -1,20 +1,13 @@
%global glib2_version 2.69.1 %global glib2_version 2.69.1
Name: libsoup3 Name: libsoup3
Version: 3.4.2 Version: 3.4.3
Release: %autorelease Release: %autorelease
Summary: Soup, an HTTP library implementation Summary: Soup, an HTTP library implementation
License: LGPL-2.0-or-later License: LGPL-2.0-or-later
URL: https://wiki.gnome.org/Projects/libsoup URL: https://wiki.gnome.org/Projects/libsoup
Source0: https://download.gnome.org/sources/libsoup/3.4/libsoup-%{version}.tar.xz Source0: https://download.gnome.org/sources/libsoup/3.4/libsoup-%{version}.tar.xz
# https://gitlab.gnome.org/GNOME/libsoup/-/merge_requests/374
# https://gitlab.gnome.org/GNOME/libsoup/-/issues/361
# https://gitlab.gnome.org/GNOME/libsoup/-/issues/348
# Fixes a couple of cases where apps can crash in connection_disconnect()
Patch: 0001-connection-manager-don-t-crash-if-connection-outlive.patch
Patch: 0002-connection-auth-don-t-crash-if-connection-outlives-t.patch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: gettext BuildRequires: gettext

View File

@ -1 +1 @@
SHA512 (libsoup-3.4.2.tar.xz) = 711007599f639625fe2efdb7adb81de2dea0035180737ce0ec8234afb034646a2b6bd9ae384a69d6591aa142e91d245d502d13e1d97cd7b51c8c87c2d925f6b3 SHA512 (libsoup-3.4.3.tar.xz) = 638b1eaefd60624f39edd0f16cea638c2edf6402318805c685f575577a228ba212c6f7ec8b64bac9f1928607e0026b69901e08b8569d179bf228e708e060a571