Re: [PATCH] Make sure that the subscription timeout is always removed



On Fr, 2012-06-29 at 23:03 +0200, Sven Neumann wrote:

Thanks. Pushed after converting tabs into spaces-

> If the GUPnPServiceProxy is unscribed (or disposed) before it actually
> got the subscription response, then SID will not have been set. The
> code used to bail out early in this case, leaving the subscription
> timeout in place. Change this so that the timeout is always removed.
> 
> Signed-off-by: Sven Neumann <s neumann raumfeld com>
> ---
>  libgupnp/gupnp-service-proxy.c |   46 ++++++++++++++++++++--------------------
>  1 file changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/libgupnp/gupnp-service-proxy.c b/libgupnp/gupnp-service-proxy.c
> index c39e9c9..4dd4eb6 100644
> --- a/libgupnp/gupnp-service-proxy.c
> +++ b/libgupnp/gupnp-service-proxy.c
> @@ -2103,10 +2103,8 @@ static void
>  unsubscribe (GUPnPServiceProxy *proxy)
>  {
>          GUPnPContext *context;
> -        SoupMessage *msg;
>          SoupSession *session;
>          SoupServer *server;
> -        char *sub_url;
>  
>          context = gupnp_service_info_get_context (GUPNP_SERVICE_INFO (proxy));
>  
> @@ -2114,35 +2112,37 @@ unsubscribe (GUPnPServiceProxy *proxy)
>          server = gupnp_context_get_server (context);
>          soup_server_remove_handler (server, proxy->priv->path);
>  
> -        if (proxy->priv->sid == NULL)
> -                return; /* No SID: nothing to unsubscribe */
> +        if (proxy->priv->sid != NULL) {
> +	        SoupMessage *msg;
> +	        char *sub_url;
>  
> -        /* Create unsubscription message */
> -        sub_url = gupnp_service_info_get_event_subscription_url
> -                                                (GUPNP_SERVICE_INFO (proxy));
> +	        /* Create unsubscription message */
> +	        sub_url = gupnp_service_info_get_event_subscription_url
> +                                                   (GUPNP_SERVICE_INFO (proxy));
>  
> -        msg = soup_message_new (GENA_METHOD_UNSUBSCRIBE, sub_url);
> +		msg = soup_message_new (GENA_METHOD_UNSUBSCRIBE, sub_url);
>  
> -        g_free (sub_url);
> +		g_free (sub_url);
>  
> -        if (msg != NULL) {
> -                /* Add headers */
> -                soup_message_headers_append (msg->request_headers,
> -                                             "SID",
> -                                             proxy->priv->sid);
> +		if (msg != NULL) {
> +		        /* Add headers */
> +		        soup_message_headers_append (msg->request_headers,
> +						     "SID",
> +						     proxy->priv->sid);
>  
> -                /* And queue it */
> -                session = gupnp_context_get_session (context);
> +			/* And queue it */
> +			session = gupnp_context_get_session (context);
>  
> -                soup_session_queue_message (session, msg, NULL, NULL);
> -        }
> +			soup_session_queue_message (session, msg, NULL, NULL);
> +		}
>  
> -        /* Reset SID */
> -        g_free (proxy->priv->sid);
> -        proxy->priv->sid = NULL;
> +		/* Reset SID */
> +		g_free (proxy->priv->sid);
> +		proxy->priv->sid = NULL;
>  
> -        /* Reset sequence number */
> -        proxy->priv->seq = 0;
> +		/* Reset sequence number */
> +		proxy->priv->seq = 0;
> +	}
>  
>          /* Remove subscription timeout */
>          if (proxy->priv->subscription_timeout_src) {




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