wispr: Add backpointer to wispr portal structure
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 7 Sep 2012 08:00:57 +0000 (11:00 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Tue, 11 Sep 2012 09:40:58 +0000 (12:40 +0300)
When calling free_connman_wispr_portal_context(), the context is
freed. Add a backpointer to the wispr portal context in order to
clear the context from the wispr_portal struct.

src/wispr.c

index f08fa7f..7ff111a 100644 (file)
@@ -69,6 +69,7 @@ struct connman_wispr_portal_context {
 
        struct connman_service *service;
        enum connman_ipconfig_type type;
+       struct connman_wispr_portal *wispr_portal;
 
        /* Portal/WISPr common */
        GWeb *web;
@@ -167,6 +168,14 @@ static void free_connman_wispr_portal_context(struct connman_wispr_portal_contex
        if (wp_context == NULL)
                return;
 
+       if (wp_context->wispr_portal != NULL) {
+               if (wp_context->wispr_portal->ipv4_context == wp_context)
+                       wp_context->wispr_portal->ipv4_context = NULL;
+
+               if (wp_context->wispr_portal->ipv6_context == wp_context)
+                       wp_context->wispr_portal->ipv6_context = NULL;
+       }
+
        if (wp_context->service != NULL)
                connman_service_unref(wp_context->service);
 
@@ -1015,6 +1024,7 @@ int __connman_wispr_start(struct connman_service *service,
 
        wp_context->service = service;
        wp_context->type = type;
+       wp_context->wispr_portal = wispr_portal;
 
        if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
                wispr_portal->ipv4_context = wp_context;