From: Ben Pfaff Date: Tue, 14 Oct 2008 22:51:26 +0000 (-0700) Subject: dhcp-client: Fix computation of timeouts. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4040288732932a373555b8d9ebad4b6bd5135ae0;p=openvswitch dhcp-client: Fix computation of timeouts. The "min_timeout" variable maintained by the DHCP client is measured in seconds from the time the state was entered, but dhclient_wait() was interpreting it as seconds from now. This made the DHCP client wait much longer than necessary in some cases. --- diff --git a/lib/dhcp-client.c b/lib/dhcp-client.c index db0bb0bd..5e54017d 100644 --- a/lib/dhcp-client.c +++ b/lib/dhcp-client.c @@ -800,7 +800,13 @@ void dhclient_wait(struct dhclient *cli) { if (cli->min_timeout != UINT_MAX) { - poll_timer_wait(sat_mul(cli->min_timeout, 1000)); + time_t now = time_now(); + unsigned int wake = sat_add(cli->state_entered, cli->min_timeout); + if (wake <= now) { + poll_immediate_wake(); + } else { + poll_timer_wait(sat_mul(sat_sub(wake, now), 1000)); + } } /* Reset timeout to 1 second. This will have no effect ordinarily, because * dhclient_run() will typically set it back to a higher value. If,