summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2020-09-18 18:19:34 -0400
committerOlivier CrĂȘte <olivier.crete@collabora.com>2020-09-18 18:19:34 -0400
commit6071a4f735fb5b36037e8e9d20c52f896b7afba4 (patch)
treebf0537fe48e6575debfec412c043c17391f80e81
parenta7c88d06beb9aab85a2e9c701e3244dc597a4f9d (diff)
downloadgupnp-igd-6071a4f735fb5b36037e8e9d20c52f896b7afba4.tar.gz
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.
-rw-r--r--libgupnp-igd/gupnp-simple-igd-thread.c13
1 files 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;