[gupnp] [PATCH] Remove soup handler before emitting signals



If a (re)subscription fails, remove the soup server handler before
emitting the "subscription-lost" signal. This fixes a potential crash
if the application code unreferences the GUPnPServiceProxy in response
to the signal.

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

diff --git a/libgupnp/gupnp-service-proxy.c b/libgupnp/gupnp-service-proxy.c
index cc8700f..c778899 100644
--- a/libgupnp/gupnp-service-proxy.c
+++ b/libgupnp/gupnp-service-proxy.c
@@ -1773,6 +1773,13 @@ subscribe_got_response (SoupSession       *session,
                                  msg->reason_phrase);
 
 hdr_err:
+                /* Remove listener */
+                context = gupnp_service_info_get_context
+                                        (GUPNP_SERVICE_INFO (proxy));
+
+                server = gupnp_context_get_server (context);
+                soup_server_remove_handler (server, proxy->priv->path);
+
                 proxy->priv->subscribed = FALSE;
 
                 g_object_notify (G_OBJECT (proxy), "subscribed");
@@ -1784,13 +1791,6 @@ hdr_err:
                                error);
 
                 g_error_free (error);
-
-                /* Remove listener */
-                context = gupnp_service_info_get_context
-                                        (GUPNP_SERVICE_INFO (proxy));
-
-                server = gupnp_context_get_server (context);
-                soup_server_remove_handler (server, proxy->priv->path);
         }
 }
 
-- 
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]