From 918f2ab3d794172fcc089be3c3f4b0fe71537652 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 4 May 2005 02:15:23 +0000 Subject: Revert the uptime() removal. Let the list sort it out... --- networking/udhcp/arpping.c | 6 +++--- networking/udhcp/common.c | 8 ++++++++ networking/udhcp/common.h | 1 + networking/udhcp/dhcpc.c | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) (limited to 'networking') diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c index da01ddd..7cc2be4 100644 --- a/networking/udhcp/arpping.c +++ b/networking/udhcp/arpping.c @@ -79,7 +79,7 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface) /* wait arp reply, and check it */ tm.tv_usec = 0; - prevTime = time(NULL); + prevTime = uptime(); while (timeout > 0) { FD_ZERO(&fdset); FD_SET(s, &fdset); @@ -97,8 +97,8 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface) break; } } - timeout -= time(NULL) - prevTime; - prevTime = time(NULL); + timeout -= uptime() - prevTime; + prevTime = uptime(); } close(s); DEBUG(LOG_INFO, "%salid arp replies for this address", rv ? "No v" : "V"); diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c index 6ca7371..bf2ac44 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c @@ -37,6 +37,14 @@ static int daemonized; +long uptime(void) +{ + struct sysinfo info; + sysinfo(&info); + return info.uptime; +} + + /* * This function makes sure our first socket calls * aren't going to fd 1 (printf badness...) and are diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index cdc51cf..ca19a24 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h @@ -39,6 +39,7 @@ enum syslog_levels { #include #endif +long uptime(void); void background(const char *pidfile); void start_log_and_pid(const char *client_server, const char *pidfile); void background(const char *pidfile); diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 028338f..8009bec 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -310,7 +310,7 @@ int main(int argc, char *argv[]) for (;;) { - tv.tv_sec = timeout - time(NULL); + tv.tv_sec = timeout - uptime(); tv.tv_usec = 0; if (listen_mode != LISTEN_NONE && fd < 0) { @@ -330,7 +330,7 @@ int main(int argc, char *argv[]) retval = select(max_fd + 1, &rfds, NULL, NULL, &tv); } else retval = 0; /* If we already timed out, fall through */ - now = time(NULL); + now = uptime(); if (retval == 0) { /* timeout dropped to zero */ switch (state) { -- cgit v1.1