fix timewarp in client (server fix later)
This commit is contained in:
@ -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;
|
||||||
time(&prevTime);
|
prevTime = uptime();
|
||||||
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 -= time(NULL) - prevTime;
|
timeout -= uptime() - prevTime;
|
||||||
time(&prevTime);
|
prevTime = uptime();
|
||||||
}
|
}
|
||||||
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");
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/sysinfo.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@ -37,6 +38,14 @@
|
|||||||
|
|
||||||
static int daemonized;
|
static int daemonized;
|
||||||
|
|
||||||
|
long uptime(void)
|
||||||
|
{
|
||||||
|
struct sysinfo info;
|
||||||
|
sysinfo(&info);
|
||||||
|
printf("uptime %d\n", info.uptime);
|
||||||
|
return info.uptime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function makes sure our first socket calls
|
* This function makes sure our first socket calls
|
||||||
|
@ -39,6 +39,7 @@ 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);
|
||||||
|
@ -188,7 +188,7 @@ int main(int argc, char *argv[])
|
|||||||
int c, len;
|
int c, len;
|
||||||
struct dhcpMessage packet;
|
struct dhcpMessage packet;
|
||||||
struct in_addr temp_addr;
|
struct in_addr temp_addr;
|
||||||
time_t now;
|
long now;
|
||||||
int max_fd;
|
int max_fd;
|
||||||
int sig;
|
int sig;
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
tv.tv_sec = timeout - time(0);
|
tv.tv_sec = timeout - uptime();
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
if (listen_mode != LISTEN_NONE && fd < 0) {
|
if (listen_mode != LISTEN_NONE && fd < 0) {
|
||||||
@ -310,7 +310,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 = time(0);
|
now = uptime();
|
||||||
if (retval == 0) {
|
if (retval == 0) {
|
||||||
/* timeout dropped to zero */
|
/* timeout dropped to zero */
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
Reference in New Issue
Block a user