From c855bddc67f218af09c742527f423075c0017aa8 Mon Sep 17 00:00:00 2001 From: daisuke niwa Date: Fri, 27 Feb 2015 09:49:39 +0100 Subject: [PATCH] Improving the time to wait for assigning IP address Framework always spends 600msec for getting IP address. DhcpStateMachine.runDhcp calls NetworkUtils.stopDhcp. After that, it calls NetworkUtils.runDhcp. In this case, wait_for_property of dhcp_utils.c calls three times. At least three times, usleep is called. So move usleep statement after property_get statement. Change-Id: I77ffb9a5a64875b47bb528b494bb60b68c1acb5a --- libnetutils/dhcp_utils.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libnetutils/dhcp_utils.c b/libnetutils/dhcp_utils.c index 0f7c384c5..70e37c676 100644 --- a/libnetutils/dhcp_utils.c +++ b/libnetutils/dhcp_utils.c @@ -72,14 +72,16 @@ static int wait_for_property(const char *name, const char *desired_value, int ma maxnaps = 1; } - while (maxnaps-- > 0) { - usleep(NAP_TIME * 1000); + while (maxnaps-- >= 0) { if (property_get(name, value, NULL)) { if (desired_value == NULL || strcmp(value, desired_value) == 0) { return 0; } } + if (maxnaps >= 0) { + usleep(NAP_TIME * 1000); + } } return -1; /* failure */ }