[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox-cvs
Subject:    [BusyBox-cvs]  busybox/networking/udhcp arpping.c, 1.7, 1.8 common.c,
From:       russ () busybox ! net (Russ Dill,,,)
Date:       2004-05-19 2:29:11
Message-ID: 20040519082909.853CEB4053 () codepoet ! org
[Download RAW message or body]

Update of /var/cvs/busybox/networking/udhcp
In directory nail:/tmp/cvs-serv27697

Modified Files:
	arpping.c common.c common.h dhcpc.c 
Log Message:
fix timewarp in client (server fix later)

Index: dhcpc.c
===================================================================
RCS file: /var/cvs/busybox/networking/udhcp/dhcpc.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- a/dhcpc.c	15 Mar 2004 08:29:00 -0000	1.17
+++ b/dhcpc.c	19 May 2004 08:29:05 -0000	1.18
@@ -188,7 +188,7 @@
 	int c, len;
 	struct dhcpMessage packet;
 	struct in_addr temp_addr;
-	time_t now;
+	long now;
 	int max_fd;
 	int sig;
 
@@ -290,7 +290,7 @@
 
 	for (;;) {
 
-		tv.tv_sec = timeout - time(0);
+		tv.tv_sec = timeout - uptime();
 		tv.tv_usec = 0;
 
 		if (listen_mode != LISTEN_NONE && fd < 0) {
@@ -310,7 +310,7 @@
 			retval = select(max_fd + 1, &rfds, NULL, NULL, &tv);
 		} else retval = 0; /* If we already timed out, fall through */
 
-		now = time(0);
+		now = uptime();
 		if (retval == 0) {
 			/* timeout dropped to zero */
 			switch (state) {

Index: arpping.c
===================================================================
RCS file: /var/cvs/busybox/networking/udhcp/arpping.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- a/arpping.c	15 Mar 2004 08:29:00 -0000	1.7
+++ b/arpping.c	19 May 2004 08:29:05 -0000	1.8
@@ -79,7 +79,7 @@
 
 	/* wait arp reply, and check it */
 	tm.tv_usec = 0;
-	time(&prevTime);
+	prevTime = uptime();
 	while (timeout > 0) {
 		FD_ZERO(&fdset);
 		FD_SET(s, &fdset);
@@ -97,8 +97,8 @@
 				break;
 			}
 		}
-		timeout -= time(NULL) - prevTime;
-		time(&prevTime);
+		timeout -= uptime() - prevTime;
+		prevTime = uptime();
 	}
 	close(s);
 	DEBUG(LOG_INFO, "%salid arp replies for this address", rv ? "No v" : "V");	

Index: common.h
===================================================================
RCS file: /var/cvs/busybox/networking/udhcp/common.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- a/common.h	14 Apr 2004 17:51:25 -0000	1.4
+++ b/common.h	19 May 2004 08:29:05 -0000	1.5
@@ -39,6 +39,7 @@
 #include <syslog.h>
 #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);

Index: common.c
===================================================================
RCS file: /var/cvs/busybox/networking/udhcp/common.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- a/common.c	19 May 2004 07:46:23 -0000	1.8
+++ b/common.c	19 May 2004 08:29:05 -0000	1.9
@@ -29,6 +29,7 @@
 #include <signal.h>
 #include <paths.h>
 #include <sys/socket.h>
+#include <sys/sysinfo.h>
 #include <stdarg.h>
 
 #include "common.h"
@@ -37,6 +38,14 @@
 
 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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic