[gupnp-igd] gupnp-simple-igd-thread: Avoid re-entrant dispose into GUPnP
- From: Olivier Crête <tester src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp-igd] gupnp-simple-igd-thread: Avoid re-entrant dispose into GUPnP
- Date: Fri, 18 Sep 2020 22:19:46 +0000 (UTC)
commit 6071a4f735fb5b36037e8e9d20c52f896b7afba4
Author: Olivier Crête <olivier crete collabora com>
Date: Fri Sep 18 18:19:34 2020 -0400
gupnp-simple-igd-thread: Avoid re-entrant dispose into GUPnP
It seems that GUPnP is really unhappy if you dispose it's objects from re-entrant
calls. So instead, just wait for the main loop to exit to do the actual disposal.
libgupnp-igd/gupnp-simple-igd-thread.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/libgupnp-igd/gupnp-simple-igd-thread.c b/libgupnp-igd/gupnp-simple-igd-thread.c
index 77bfebd..5177d12 100644
--- a/libgupnp-igd/gupnp-simple-igd-thread.c
+++ b/libgupnp-igd/gupnp-simple-igd-thread.c
@@ -61,6 +61,8 @@ struct thread_data
GMainContext *context;
GMainLoop *loop;
gboolean all_mappings_deleted;
+
+ GUPnPSimpleIgdThread *self;
};
struct _GUPnPSimpleIgdThreadPrivate
@@ -210,6 +212,11 @@ gupnp_simple_igd_thread_dispose (GObject *object)
if (self->priv->thread_data->loop)
g_main_loop_quit (self->priv->thread_data->loop);
GUPNP_SIMPLE_IGD_THREAD_UNLOCK (self);
+
+ if (self->priv->thread_data->loop != NULL) {
+ self->priv->thread_data->self = g_object_ref (self);
+ return;
+ }
}
else if (self->priv->thread)
{
@@ -298,10 +305,12 @@ thread_func (gpointer dat)
data->all_mappings_deleted = TRUE;
g_mutex_unlock (&data->mutex);
- g_main_context_pop_thread_default (data->context);
-
g_main_loop_unref (loop);
+ if (data->self)
+ g_object_unref (data->self);
+
+ g_main_context_pop_thread_default (data->context);
thread_data_dec (data);
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]