[gupnp] [PATCH] fix race condition: subscribe vs dispose



From: Henry Hoegelow <h hoegelow raumfeld com>

In dispose() unsubscribe again after being sure that all pending
messages (incl ev. pending subscriptions) have been cancelled.

Signed-off-by: Sven Neumann <s neumann raumfeld com>
---
 libgupnp/gupnp-service-proxy.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/libgupnp/gupnp-service-proxy.c b/libgupnp/gupnp-service-proxy.c
index 7326c97..7c18e48 100644
--- a/libgupnp/gupnp-service-proxy.c
+++ b/libgupnp/gupnp-service-proxy.c
@@ -245,12 +245,23 @@ gupnp_service_proxy_dispose (GObject *object)
                                             proxy->priv->pending_messages);
         }
 
+	/* Unsubscribe again, in case a pending subscription response
+	 * came while we were in unsubscribe(). This definitly happens
+	 * sometimes since the pending messages are cancelled after
+	 * unsubscribe.
+         */
+        if (proxy->priv->subscribed) {
+                unsubscribe (proxy);
+
+                proxy->priv->subscribed = FALSE;
+        }
+
         /* Cancel pending notifications */
         if (proxy->priv->notify_idle_src) {
                 g_source_destroy (proxy->priv->notify_idle_src);
                 proxy->priv->notify_idle_src = NULL;
         }
-        
+
         while (proxy->priv->pending_notifies) {
                 xmlFreeDoc (proxy->priv->pending_notifies->data);
                 proxy->priv->pending_notifies =
-- 
1.6.0.4

--
To unsubscribe send a mail to gupnp+unsubscribe\@o-hand.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]