]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Tweak README about monotonic, and improve warning message.
authorRoy Marples <roy@marples.name>
Fri, 1 Aug 2008 08:41:25 +0000 (08:41 +0000)
committerRoy Marples <roy@marples.name>
Fri, 1 Aug 2008 08:41:25 +0000 (08:41 +0000)
README
client.c
common.c

diff --git a/README b/README
index d84ab755f8cdb5a632679c91d513dc494ed4afcb..ef7e78420add22adfacd80f06ae9bf2aee2714d5 100644 (file)
--- a/README
+++ b/README
@@ -15,12 +15,15 @@ If you're cross compiling you may need to set the below knobs to avoid
 automatic tests.
 OS=BSD | Linux
 
-If you're building for a NOMMU system where fork() does not work, you should
-add -DTHERE_IS_NO_FORK to your CPPFLAGS.
+If you're building for an MMU-less system where fork() does not work, you
+should add -DTHERE_IS_NO_FORK to your CPPFLAGS.
 
 dhcpcd will try and use a monotonic clock when possible.
 Some libc implementations do not correctly report that they have a monotonic
 clock, but they have the headers to make it work. dhcpcd will warn about this.
+Without a monotonic clock, we fall victim of the year 2038 time_t bug on
+32-bit platforms AND the timers will be sufer from clock skew if the system
+clock changes.
 To force the use of a monotonic clock you can add -DFORCE_MONOTONIC
 to your CPPFLAGS.
 
index f68bafa6683e813f3eda3e614184f1fc9d19fa76..346da0ceec135445fff176e5d5eae2432c736379 100644 (file)
--- a/client.c
+++ b/client.c
@@ -870,7 +870,7 @@ wait_for_fd(struct if_state *state, int *fd)
                else if (iface->arp_fd != -1 && FD_ISSET(iface->arp_fd, &fds))
                        *fd = iface->arp_fd;
        } else {
-               /* select and poll are CAN timeout BEFORE the timeout.
+               /* select and poll CAN timeout BEFORE the timeout.
                 * This is a sad state of affairs, so we need to reduce the
                 * lowest timeout to -1 so it REALLY has timed out. */
                ref = get_lowest_timer(state);
index 9911b3450ad7c0f341b0d8c9fef80a7062608081..9bedc6de28aeb4107e95743046192da875dc0864 100644 (file)
--- a/common.c
+++ b/common.c
@@ -184,13 +184,14 @@ set_nonblock(int fd)
  * Which is why we use CLOCK_MONOTONIC, but it is not available on all
  * platforms.
  */
+#define NO_MONOTONIC "host does not support a montonic clock - timing can skew"
 int
 get_monotonic(struct timeval *tp)
 {
+       static int posix_clock_set = 0;
 #if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC)
        struct timespec ts;
        static clockid_t posix_clock;
-       static int posix_clock_set = 0;
 
 #ifdef FORCE_MONOTONIC
        if (!posix_clock_set) {
@@ -205,7 +206,7 @@ get_monotonic(struct timeval *tp)
                        clock_monotonic = 1;
                } else {
                        posix_clock = CLOCK_REALTIME;
-                       logger(LOG_WARNING, "host does not support a monotonic clock");
+                       logger(LOG_WARNING, NO_MONOTONIC);
                }
 
                posix_clock_set = 1;
@@ -219,6 +220,11 @@ get_monotonic(struct timeval *tp)
        tp->tv_usec = ts.tv_nsec / 1000;
        return 0;
 #else
+
+       if (!posix_clock_set) {
+               logger(LOG_WARNING, NO_MONOTONIC);
+               posix_clock_set = 1;
+       }
        return gettimeofday(tp, NULL);
 #endif
 }