If the lease time is 1, then we wouldn't wait; that's a bug. Clean up an obnoxious conditional.
Change-Id: I25ad3c5ac3510d56a0dc3d37b464ca002236875b Signed-off-by: Dan Cross <[email protected]> --- tools/apps/ipconfig/main.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tools/apps/ipconfig/main.c b/tools/apps/ipconfig/main.c index db353bd..a19197b 100644 --- a/tools/apps/ipconfig/main.c +++ b/tools/apps/ipconfig/main.c @@ -952,20 +952,17 @@ static void *dhcpwatchthr(void *arg) uint32_t t; int needconfig = (arg == NULL); - // procsetname("dhcpwatch"); /* keep trying to renew the lease */ for (;;) { + secs = conf.lease / 2; if (conf.lease == 0) secs = 5; - else - secs = conf.lease >> 1; /* avoid overflows */ for (s = secs; s > 0; s -= t) { - if (s > Maxsleep) + t = s; + if (t > Maxsleep) t = Maxsleep; - else - t = s; usleep(t * 1000 * 1000); } @@ -1279,9 +1276,8 @@ void dhcprecv(void) /* get plan9-specific options */ n = optgetvec(bp->optdata, OBvendorinfo, vopts, sizeof(vopts) - 1); if (n > 0 && parseoptions(vopts, n) == 0) { - if (validip(conf.fs) && Oflag) - n = 1; - else { + n = 1; + if (!validip(conf.fs) && Oflag) { n = optgetp9addrs(vopts, OP9fs, conf.fs, 2); if (n == 0) n = optgetaddrs(vopts, OP9fsv4, conf.fs, 2); @@ -1289,9 +1285,8 @@ void dhcprecv(void) for (i = 0; i < n; i++) DEBUG("fs=%R ", conf.fs + i * IPaddrlen); - if (validip(conf.auth) && Oflag) - n = 1; - else { + n = 1; + if (!validip(conf.auth) && Oflag) { n = optgetp9addrs(vopts, OP9auth, conf.auth, 2); if (n == 0) n = optgetaddrs(vopts, OP9authv4, conf.auth, 2); -- 2.8.0.rc3.226.g39d4020 -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
