dhcp: Stop pending gdhcp client requests
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Thu, 10 Mar 2011 09:43:43 +0000 (10:43 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 11 Mar 2011 01:15:38 +0000 (02:15 +0100)
When remove_network is called there could be still a pending
dhcp request in the dhcp client.

Fixes BMC#13947

src/dhcp.c

index bedc555..6fda67d 100644 (file)
@@ -314,9 +314,14 @@ static int dhcp_release(struct connman_dhcp *dhcp)
 {
        DBG("dhcp %p", dhcp);
 
+       if (dhcp->dhcp_client == NULL)
+               return 0;
+
        g_dhcp_client_stop(dhcp->dhcp_client);
        g_dhcp_client_unref(dhcp->dhcp_client);
 
+       dhcp->dhcp_client = NULL;
+
        return 0;
 }
 
@@ -326,6 +331,8 @@ static void remove_network(gpointer user_data)
 
        DBG("dhcp %p", dhcp);
 
+       dhcp_release(dhcp);
+
        dhcp_free(dhcp);
        g_free(dhcp);
 }