Return to mainloop before starting DHCP procedure
authorMarcel Holtmann <marcel@holtmann.org>
Wed, 24 Nov 2010 13:53:35 +0000 (14:53 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 24 Nov 2010 13:53:35 +0000 (14:53 +0100)
Just before starting the DHCP procedure return to mainloop first. This
fixes some cases where the interface is not yet up. This happens mainly
when using Bluetooth PAN connections where the network interface will be
newly created every single time.

plugins/dhcp.c

index 73c975d..e4dff18 100644 (file)
@@ -111,6 +111,15 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data)
        connman_dhcp_bound(dhcp);
 }
 
+static gboolean start_dhcp(gpointer user_data)
+{
+       GDHCPClient *dhcp_client = user_data;
+
+       g_dhcp_client_start(dhcp_client);
+
+       return FALSE;
+}
+
 static int dhcp_request(struct connman_dhcp *dhcp)
 {
        GDHCPClient *dhcp_client;
@@ -155,7 +164,9 @@ static int dhcp_request(struct connman_dhcp *dhcp)
 
        g_dhcp_client_ref(dhcp_client);
 
-       return g_dhcp_client_start(dhcp_client);
+       g_timeout_add_seconds(0, start_dhcp, dhcp_client);
+
+       return 0;
 }
 
 static int dhcp_release(struct connman_dhcp *dhcp)