diff -uprN bird-1.0.11/sysdep/unix/io.c bird-1.0.11n/sysdep/unix/io.c --- bird-1.0.11/sysdep/unix/io.c 2008-08-21 17:28:49.000000000 +0200 +++ bird-1.0.11n/sysdep/unix/io.c 2008-08-21 17:28:04.000000000 +0200 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -18,6 +19,8 @@ #include #include +#include + #include "nest/bird.h" #include "lib/lists.h" #include "lib/resource.h" @@ -1093,6 +1096,31 @@ sk_dump_all(void) volatile int async_config_flag; /* Asynchronous reconfiguration/dump scheduled */ volatile int async_dump_flag; +static time_t +monotonic_time(void) +{ + long long int rv; + static int overflow = 0; + static clock_t old_val = 0; + clock_t new_val = times(NULL); + + if (new_val == -1) + die("times: %m"); + + if (new_val < old_val) { + log(L_INFO "timewrap"); + overflow++; + } + + rv = overflow; + rv *= 0x100000000ll; + rv += new_val; + old_val = new_val; + + return rv / HZ; +} + + void io_init(void) { @@ -1101,7 +1129,7 @@ io_init(void) init_list(&sock_list); init_list(&global_event_list); krt_io_init(); - now = time(NULL); + now = monotonic_time(); srandom((int) now); } @@ -1119,7 +1147,7 @@ io_loop(void) for(;;) { events = ev_run_list(&global_event_list); - now = time(NULL); + now = monotonic_time(); tout = tm_first_shot(); if (tout <= now) {