commit:     3132f09fd30bb8b5a8b73d79ec188c0170e5091a
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Sun Apr 13 14:51:21 2025 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Sun Apr 13 18:28:38 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3132f09f

net-libs/libnice: Switch to net-libs/gupnp-igd:1.6

Backport some git master fixes, see also:
https://gitlab.freedesktop.org/libnice/libnice/-/merge_requests/278
https://gitlab.freedesktop.org/libnice/libnice/-/issues/198
https://gitlab.freedesktop.org/libnice/libnice/-/merge_requests/282
https://gitlab.gnome.org/GNOME/glib/-/issues/3528

Other distros do the same. Tests passed.

Bug: https://bugs.gentoo.org/948374
Bug: https://bugs.gentoo.org/953635
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 ...libnice-0.1.22-fix-concurrent-tcp-sending.patch |  34 ++++
 .../libnice-0.1.22-fix-test-new-trickle.patch      | 226 +++++++++++++++++++++
 .../files/libnice-0.1.22-gupnp-igd-1.6.patch       |  14 ++
 ...nice-0.1.22-stop-leaking-StunResolverData.patch |  36 ++++
 net-libs/libnice/libnice-0.1.22-r1.ebuild          |  67 ++++++
 5 files changed, 377 insertions(+)

diff --git 
a/net-libs/libnice/files/libnice-0.1.22-fix-concurrent-tcp-sending.patch 
b/net-libs/libnice/files/libnice-0.1.22-fix-concurrent-tcp-sending.patch
new file mode 100644
index 000000000000..836595a2b271
--- /dev/null
+++ b/net-libs/libnice/files/libnice-0.1.22-fix-concurrent-tcp-sending.patch
@@ -0,0 +1,34 @@
+From 55ff684d0989ffd65d02fafe1d2a43309576b8fa Mon Sep 17 00:00:00 2001
+From: jiangpeilong <[email protected]>
+Date: Thu, 22 Aug 2024 21:12:11 +0800
+Subject: [PATCH] Fix TCP concurrent sending problem
+
+---
+ socket/tcp-bsd.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/socket/tcp-bsd.c b/socket/tcp-bsd.c
+index 194f29f5..25580353 100644
+--- a/socket/tcp-bsd.c
++++ b/socket/tcp-bsd.c
+@@ -312,6 +312,8 @@ socket_send_message (NiceSocket *sock,
+   if (priv->error)
+     return -1;
+ 
++  g_mutex_lock(&mutex);
++
+   message_len = output_message_get_size (message);
+ 
+   /* First try to send the data, don't send it later if it can be sent now
+@@ -353,6 +355,8 @@ socket_send_message (NiceSocket *sock,
+     }
+   }
+ 
++  g_mutex_unlock(&mutex);
++
+   return ret;
+ }
+ 
+-- 
+GitLab
+

diff --git a/net-libs/libnice/files/libnice-0.1.22-fix-test-new-trickle.patch 
b/net-libs/libnice/files/libnice-0.1.22-fix-test-new-trickle.patch
new file mode 100644
index 000000000000..112b95dbba44
--- /dev/null
+++ b/net-libs/libnice/files/libnice-0.1.22-fix-test-new-trickle.patch
@@ -0,0 +1,226 @@
+From 37eeeb1a750bf2dd6d5769d759069e95dd1b8493 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= <[email protected]>
+Date: Thu, 14 Nov 2024 11:16:14 -0500
+Subject: [PATCH] test-new-trickle: Remove cancellable as a wakeup mechanism
+
+Just wake up the main context directly instead. This was causing a regression
+with GLib 2.83
+
+Fixes #198
+---
+ tests/test-new-trickle.c | 36 +++---------------------------------
+ 1 file changed, 3 insertions(+), 33 deletions(-)
+
+diff --git a/tests/test-new-trickle.c b/tests/test-new-trickle.c
+index da808dae..e80048e5 100644
+--- a/tests/test-new-trickle.c
++++ b/tests/test-new-trickle.c
+@@ -67,7 +67,6 @@ static GCond *stun_thread_signal_ptr = &stun_thread_signal;
+ 
+ static NiceComponentState global_lagent_state = NICE_COMPONENT_STATE_LAST;
+ static NiceComponentState global_ragent_state = NICE_COMPONENT_STATE_LAST;
+-static GCancellable *global_cancellable;
+ static gboolean exit_stun_thread = FALSE;
+ static gboolean lagent_candidate_gathering_done = FALSE;
+ static gboolean ragent_candidate_gathering_done = FALSE;
+@@ -225,7 +224,7 @@ recv_packet:
+   buf_len = stun_agent_finish_message (agent, &response, NULL, 0);
+ 
+ send_buf:
+-  g_cancellable_cancel (global_cancellable);
++  g_main_context_wakeup (NULL);
+   g_debug ("Ready to send a STUN response");
+   g_assert_true (g_mutex_trylock (stun_mutex_ptr));
+   got_stun_packet = TRUE;
+@@ -292,7 +291,6 @@ static void cb_candidate_gathering_done(NiceAgent *agent, 
guint stream_id, gpoin
+     g_debug ("ragent finished gathering candidates");
+     ragent_candidate_gathering_done = TRUE;
+   }
+-  g_cancellable_cancel (global_cancellable);
+ }
+ 
+ static void cb_nice_recv (NiceAgent *agent, guint stream_id, guint 
component_id, guint len, gchar *buf, gpointer user_data)
+@@ -309,7 +307,7 @@ static void cb_nice_recv (NiceAgent *agent, guint 
stream_id, guint component_id,
+     g_debug ("test-tricklemode:%s: ragent recieved %d bytes : quit mainloop",
+              G_STRFUNC, len);
+     data_received = TRUE;
+-    g_cancellable_cancel (global_cancellable);
++    g_main_context_wakeup (NULL);
+   }
+ }
+ 
+@@ -333,7 +331,7 @@ static void cb_component_state_changed (NiceAgent *agent, 
guint stream_id, guint
+     send_stun = TRUE;
+     g_cond_signal (stun_signal_ptr);
+     g_mutex_unlock (stun_mutex_ptr);
+-    g_cancellable_cancel (global_cancellable);
++    g_main_context_wakeup (NULL);
+   }
+ 
+   if(GPOINTER_TO_UINT(data) == 1 && state == NICE_COMPONENT_STATE_READY) {
+@@ -492,7 +490,6 @@ static void standard_test(NiceAgent *lagent, NiceAgent 
*ragent)
+   nice_agent_gather_candidates (ragent, global_rs_id);
+   while (!ragent_candidate_gathering_done)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+   g_assert_true (ragent_candidate_gathering_done);
+   g_assert_true (nice_agent_peer_candidate_gathering_done (lagent, 
global_ls_id));
+ 
+@@ -503,7 +500,6 @@ static void standard_test(NiceAgent *lagent, NiceAgent 
*ragent)
+ 
+   while (!data_received)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+   g_assert_true (global_lagent_state >= NICE_COMPONENT_STATE_CONNECTED &&
+             data_received);
+ 
+@@ -513,14 +509,12 @@ static void standard_test(NiceAgent *lagent, NiceAgent 
*ragent)
+ 
+   while (!lagent_candidate_gathering_done)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+ 
+   g_assert_true (lagent_candidate_gathering_done);
+   g_assert_true (nice_agent_peer_candidate_gathering_done (ragent, 
global_rs_id));
+ 
+   while (global_ragent_state < NICE_COMPONENT_STATE_CONNECTED)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+ 
+   g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_READY);
+   g_assert_cmpint (global_ragent_state, >=, NICE_COMPONENT_STATE_CONNECTED);
+@@ -542,14 +536,12 @@ static void bad_credentials_test(NiceAgent *lagent, 
NiceAgent *ragent)
+   nice_agent_gather_candidates (lagent, global_ls_id);
+   while (!got_stun_packet)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+   g_assert_true (global_lagent_state == NICE_COMPONENT_STATE_GATHERING &&
+             !lagent_candidate_gathering_done);
+ 
+   nice_agent_gather_candidates (ragent, global_rs_id);
+   while (!ragent_candidate_gathering_done)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+   g_assert_true (ragent_candidate_gathering_done);
+   g_assert_true (nice_agent_peer_candidate_gathering_done (lagent, 
global_ls_id));
+ 
+@@ -558,7 +550,6 @@ static void bad_credentials_test(NiceAgent *lagent, 
NiceAgent *ragent)
+ 
+   while (global_lagent_state != NICE_COMPONENT_STATE_FAILED)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+ 
+   // Set the correct credentials and swap candidates
+   g_debug ("Setting local candidates of ragent as remote candidates of 
lagent");
+@@ -571,7 +562,6 @@ static void bad_credentials_test(NiceAgent *lagent, 
NiceAgent *ragent)
+ 
+   while (!data_received)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+ 
+   g_assert_true (data_received);
+   g_assert_cmpint (global_lagent_state, ==, NICE_COMPONENT_STATE_READY);
+@@ -580,7 +570,6 @@ static void bad_credentials_test(NiceAgent *lagent, 
NiceAgent *ragent)
+   // Wait for lagent to finish gathering candidates
+   while (!lagent_candidate_gathering_done)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+ 
+   g_assert_true (lagent_candidate_gathering_done);
+   g_assert_true (nice_agent_peer_candidate_gathering_done (ragent, 
global_rs_id));
+@@ -599,14 +588,12 @@ static void bad_candidate_test(NiceAgent 
*lagent,NiceAgent *ragent)
+   nice_agent_gather_candidates (lagent, global_ls_id);
+   while (!got_stun_packet)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+   g_assert_true (global_lagent_state == NICE_COMPONENT_STATE_GATHERING &&
+             !lagent_candidate_gathering_done);
+ 
+   nice_agent_gather_candidates (ragent, global_rs_id);
+   while (!ragent_candidate_gathering_done)
+       g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+ 
+   g_assert_true (ragent_candidate_gathering_done);
+   g_assert_true (nice_agent_peer_candidate_gathering_done (lagent, 
global_ls_id));
+@@ -616,14 +603,12 @@ static void bad_candidate_test(NiceAgent 
*lagent,NiceAgent *ragent)
+   // lagent will finish candidate gathering causing this mainloop to quit
+   while (!lagent_candidate_gathering_done)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+ 
+   g_assert_true (nice_agent_peer_candidate_gathering_done (ragent, 
global_rs_id));
+ 
+   // connchecks will fail causing this mainloop to quit
+   while (global_lagent_state != NICE_COMPONENT_STATE_FAILED)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+ 
+   g_assert_true (global_lagent_state == NICE_COMPONENT_STATE_FAILED &&
+             !data_received);
+@@ -638,7 +623,6 @@ static void bad_candidate_test(NiceAgent *lagent,NiceAgent 
*ragent)
+ 
+   while (!data_received)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+ 
+   g_assert_true (lagent_candidate_gathering_done);
+ 
+@@ -659,20 +643,17 @@ static void new_candidate_test(NiceAgent *lagent, 
NiceAgent *ragent)
+   nice_agent_gather_candidates (lagent, global_ls_id);
+   while (!got_stun_packet)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+   g_assert_true (global_lagent_state == NICE_COMPONENT_STATE_GATHERING &&
+             !lagent_candidate_gathering_done);
+ 
+   nice_agent_gather_candidates (ragent, global_rs_id);
+   while (!ragent_candidate_gathering_done)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+   g_assert_true (nice_agent_peer_candidate_gathering_done (lagent, 
global_ls_id));
+ 
+   // Wait for data
+   while (!data_received)
+       g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+   g_assert_true (data_received);
+ 
+   // Data arrived, signal STUN thread to send STUN response
+@@ -684,7 +665,6 @@ static void new_candidate_test(NiceAgent *lagent, 
NiceAgent *ragent)
+   // Wait for lagent to finish gathering candidates
+   while (!lagent_candidate_gathering_done)
+     g_main_context_iteration (NULL, TRUE);
+-  g_cancellable_reset (global_cancellable);
+   g_assert_true (nice_agent_peer_candidate_gathering_done (ragent, 
global_rs_id));
+ 
+   g_assert_true (lagent_candidate_gathering_done);
+@@ -719,14 +699,8 @@ int main(void)
+   NiceAgent *lagent = NULL, *ragent = NULL;
+   GThread *stun_thread = NULL;
+   NiceAddress baseaddr;
+-  GSource *src;
+   int sock;
+ 
+-  global_cancellable = g_cancellable_new ();
+-  src = g_cancellable_source_new (global_cancellable);
+-  g_source_set_dummy_callback (src);
+-  g_source_attach (src, NULL);
+-
+   sock = listen_socket (&stun_port);
+ 
+   if (sock == -1) {
+@@ -795,10 +769,6 @@ int main(void)
+   g_object_unref (ragent);
+ 
+   g_thread_join (stun_thread);
+-  g_object_unref (global_cancellable);
+-
+-  g_source_destroy (src);
+-  g_source_unref (src);
+ 
+   WAIT_UNTIL_UNSET (lagent, NULL);
+   WAIT_UNTIL_UNSET (ragent, NULL);
+-- 
+GitLab
+

diff --git a/net-libs/libnice/files/libnice-0.1.22-gupnp-igd-1.6.patch 
b/net-libs/libnice/files/libnice-0.1.22-gupnp-igd-1.6.patch
new file mode 100644
index 000000000000..5f110418d4c3
--- /dev/null
+++ b/net-libs/libnice/files/libnice-0.1.22-gupnp-igd-1.6.patch
@@ -0,0 +1,14 @@
+https://bugs.gentoo.org/948374
+https://bugs.gentoo.org/953635
+
+--- a/meson.build      2024-03-04 21:12:14.000000000 +0100
++++ b/meson.build      2025-04-13 16:44:16.820025467 +0200
+@@ -276,7 +276,7 @@
+ cdata.set('HAVE_GSTREAMER', gst_dep.found(), description: 'Build GStreamer 
plugin')
+ 
+ # GUPnP IGD
+-gupnp_igd_dep = dependency('gupnp-igd-1.0', version: gupnp_igd_req, required: 
get_option('gupnp'))
++gupnp_igd_dep = dependency('gupnp-igd-1.6', version: gupnp_igd_req, required: 
get_option('gupnp'))
+ cdata.set('HAVE_GUPNP', gupnp_igd_dep.found(), description: 'Use the GUPnP 
IGD library')
+ 
+ libm = cc.find_library('m', required: false)

diff --git 
a/net-libs/libnice/files/libnice-0.1.22-stop-leaking-StunResolverData.patch 
b/net-libs/libnice/files/libnice-0.1.22-stop-leaking-StunResolverData.patch
new file mode 100644
index 000000000000..be7e4080b9bf
--- /dev/null
+++ b/net-libs/libnice/files/libnice-0.1.22-stop-leaking-StunResolverData.patch
@@ -0,0 +1,36 @@
+From ac4bb22ebbfce712729aec277259c5ea9254189a Mon Sep 17 00:00:00 2001
+From: Albert Sjolund <[email protected]>
+Date: Fri, 3 Jan 2025 09:16:55 +0100
+Subject: [PATCH] agent: stop leaking StunResolverData
+
+if agent is null StunResolverData would leak as free would
+not be reached.
+The disposal function doesn't perform any freeing logic of the
+underlying StunResolverData, so it is only here that they are freed.
+When TurnResolverData is freed, there is no if statement blocking it.
+---
+ agent/agent.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/agent/agent.c b/agent/agent.c
+index 8bab9f89..d98b5b2a 100644
+--- a/agent/agent.c
++++ b/agent/agent.c
+@@ -2720,11 +2720,11 @@ stun_server_resolved_cb (GObject *src, GAsyncResult 
*result,
+ 
+   agent = g_weak_ref_get (&data->agent_ref);
+   g_weak_ref_clear (&data->agent_ref);
+-  if (agent == NULL)
+-    return;
++
+   stream_id = data->stream_id;
+   g_slice_free (struct StunResolverData, data);
+-
++  if (agent == NULL)
++    return;
+   agent->stun_resolving_list = g_slist_remove_all (agent->stun_resolving_list,
+       data);
+ 
+-- 
+GitLab
+

diff --git a/net-libs/libnice/libnice-0.1.22-r1.ebuild 
b/net-libs/libnice/libnice-0.1.22-r1.ebuild
new file mode 100644
index 000000000000..3564406c64ae
--- /dev/null
+++ b/net-libs/libnice/libnice-0.1.22-r1.ebuild
@@ -0,0 +1,67 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit meson-multilib xdg
+
+DESCRIPTION="Implementation of the Interactice Connectivity Establishment 
standard (ICE)"
+HOMEPAGE="https://libnice.freedesktop.org/";
+SRC_URI="https://libnice.freedesktop.org/releases/${P}.tar.gz";
+
+LICENSE="|| ( MPL-1.1 LGPL-2.1 )"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~ppc ~ppc64 ~riscv ~sparc 
~x86 ~amd64-linux ~x86-linux ~ppc-macos"
+IUSE="+gnutls gtk-doc +introspection test +upnp"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+       >=dev-libs/glib-2.54:2[${MULTILIB_USEDEP}]
+       introspection? ( >=dev-libs/gobject-introspection-1.30.0:= )
+       gnutls? ( >=net-libs/gnutls-2.12.0:0=[${MULTILIB_USEDEP}] )
+       !gnutls? ( dev-libs/openssl:0=[${MULTILIB_USEDEP}] )
+       upnp? ( net-libs/gupnp-igd:1.6=[${MULTILIB_USEDEP}] )
+"
+DEPEND="${RDEPEND}"
+BDEPEND="
+       dev-util/glib-utils
+       virtual/pkgconfig
+       gtk-doc? (
+               app-text/docbook-xml-dtd:4.1.2
+               dev-util/gtk-doc
+       )
+"
+
+PATCHES=(
+       "${FILESDIR}/${PN}-0.1.19-remove-graphviz-dependency.patch" # 
downstream; bugs 877451, 889820
+       "${FILESDIR}/${P}-gupnp-igd-1.6.patch" # downstream; bugs 948374, 953635
+       # upstream git master:
+       "${FILESDIR}/${P}-fix-concurrent-tcp-sending.patch"
+       "${FILESDIR}/${P}-fix-test-new-trickle.patch"
+       "${FILESDIR}/${P}-stop-leaking-StunResolverData.patch"
+)
+
+src_prepare() {
+       default
+
+       # Broken w/ network-sandbox on (bug #847844)
+       sed -i -e '/test-set-port-range/d' tests/meson.build || die
+}
+
+multilib_src_configure() {
+       # gstreamer plugin split off into media-plugins/gst-plugins-libnice
+       local emesonargs=(
+               -Dgstreamer=disabled
+               -Dcrypto-library=$(usex gnutls gnutls openssl)
+               $(meson_native_use_feature introspection)
+               $(meson_feature test tests)
+               $(meson_feature upnp gupnp)
+               $(meson_native_use_feature gtk-doc gtk_doc)
+       )
+
+       meson_src_configure
+}
+
+multilib_src_install_all() {
+       einstalldocs
+}

Reply via email to