Patch from Shaun Jackman:
Replace uptime with time(NULL). time is more portable than uptime and eliminates the need to define uptime, reducing code size slightly.
This commit is contained in:
parent
15d3f7f143
commit
8b80c71d70
@ -79,7 +79,7 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
|
|||||||
|
|
||||||
/* wait arp reply, and check it */
|
/* wait arp reply, and check it */
|
||||||
tm.tv_usec = 0;
|
tm.tv_usec = 0;
|
||||||
prevTime = uptime();
|
prevTime = time(NULL);
|
||||||
while (timeout > 0) {
|
while (timeout > 0) {
|
||||||
FD_ZERO(&fdset);
|
FD_ZERO(&fdset);
|
||||||
FD_SET(s, &fdset);
|
FD_SET(s, &fdset);
|
||||||
@ -97,8 +97,8 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timeout -= uptime() - prevTime;
|
timeout -= time(NULL) - prevTime;
|
||||||
prevTime = uptime();
|
prevTime = time(NULL);
|
||||||
}
|
}
|
||||||
close(s);
|
close(s);
|
||||||
DEBUG(LOG_INFO, "%salid arp replies for this address", rv ? "No v" : "V");
|
DEBUG(LOG_INFO, "%salid arp replies for this address", rv ? "No v" : "V");
|
||||||
|
@ -37,14 +37,6 @@
|
|||||||
|
|
||||||
static int daemonized;
|
static int daemonized;
|
||||||
|
|
||||||
long uptime(void)
|
|
||||||
{
|
|
||||||
struct sysinfo info;
|
|
||||||
sysinfo(&info);
|
|
||||||
return info.uptime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function makes sure our first socket calls
|
* This function makes sure our first socket calls
|
||||||
* aren't going to fd 1 (printf badness...) and are
|
* aren't going to fd 1 (printf badness...) and are
|
||||||
|
@ -39,7 +39,6 @@ enum syslog_levels {
|
|||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
long uptime(void);
|
|
||||||
void background(const char *pidfile);
|
void background(const char *pidfile);
|
||||||
void start_log_and_pid(const char *client_server, const char *pidfile);
|
void start_log_and_pid(const char *client_server, const char *pidfile);
|
||||||
void background(const char *pidfile);
|
void background(const char *pidfile);
|
||||||
|
@ -310,7 +310,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
tv.tv_sec = timeout - uptime();
|
tv.tv_sec = timeout - time(NULL);
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
if (listen_mode != LISTEN_NONE && fd < 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);
|
retval = select(max_fd + 1, &rfds, NULL, NULL, &tv);
|
||||||
} else retval = 0; /* If we already timed out, fall through */
|
} else retval = 0; /* If we already timed out, fall through */
|
||||||
|
|
||||||
now = uptime();
|
now = time(NULL);
|
||||||
if (retval == 0) {
|
if (retval == 0) {
|
||||||
/* timeout dropped to zero */
|
/* timeout dropped to zero */
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
Loading…
Reference in New Issue
Block a user