From: Roy Marples Date: Fri, 25 Jul 2008 20:35:41 +0000 (+0000) Subject: Report more accurate seconds. X-Git-Tag: v4.0.2~130 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de01f4bf0a54b6433e6a8b8ee526c275a2db89a9;p=thirdparty%2Fdhcpcd.git Report more accurate seconds. --- diff --git a/client.c b/client.c index a058c24f..4e0ce35e 100644 --- a/client.c +++ b/client.c @@ -738,6 +738,7 @@ wait_for_fd(struct if_state *state, int *fd) time_t msecs = -1; static time_t last_stop_sec = 0, last_timeout_sec = 0; static long int last_stop_usec = 0, last_timeout_usec = 0; + double secs; /* We always listen to signals */ fds[nfds].fd = state->signal_fd; @@ -798,20 +799,20 @@ wait_for_fd(struct if_state *state, int *fd) if (ref) { timersub(ref, &now, &tout); - msecs = tout.tv_sec * 1000 + (tout.tv_usec + 999) / 1000; + secs = tout.tv_sec * 1.0 + tout.tv_usec * 1.0e-6; /* Only report waiting time if changed */ if (last_stop_sec != state->stop.tv_sec || last_stop_usec != state->stop.tv_usec || last_timeout_sec != state->timeout.tv_sec || last_timeout_usec != state->timeout.tv_usec) { - logger(LOG_DEBUG, "waiting for %.2f seconds", - (float)msecs / 1000); + logger(LOG_DEBUG, "waiting for %0.2f seconds", secs); last_stop_sec = state->stop.tv_sec; last_stop_usec = state->stop.tv_usec; last_timeout_sec = state->timeout.tv_sec; last_timeout_usec = state->timeout.tv_usec; } + msecs = tout.tv_sec * 1000 + (tout.tv_usec + 999) / 1000; } r = poll(fds, nfds, msecs);