4 #include <sys/socket.h>
5 #include <netinet/in.h>
7 +#include <sys/sysinfo.h>
11 @@ -227,6 +228,7 @@ static struct subprocess *children;
13 /* Prototypes for procedures local to this file. */
15 +static void check_time(void);
16 static void setup_signals __P((void));
17 static void create_pidfile __P((int pid));
18 static void create_linkpidfile __P((int pid));
19 @@ -532,6 +534,7 @@ main(argc, argv)
20 info("Starting link");
24 gettimeofday(&start_time, NULL);
25 script_unsetenv("CONNECT_TIME");
26 script_unsetenv("BYTES_SENT");
27 @@ -1264,6 +1267,36 @@ struct callout {
29 static struct callout *callout = NULL; /* Callout list */
30 static struct timeval timenow; /* Current time */
31 +static long uptime_diff = 0;
32 +static int uptime_diff_set = 0;
34 +static void check_time(void)
41 + gettimeofday(&t, NULL);
43 + new_diff = t.tv_sec - i.uptime;
45 + if (!uptime_diff_set) {
46 + uptime_diff = new_diff;
47 + uptime_diff_set = 1;
51 + if ((new_diff - 5 > uptime_diff) || (new_diff + 5 < uptime_diff)) {
52 + /* system time has changed, update counters and timeouts */
53 + info("System time change detected.");
54 + start_time.tv_sec += new_diff - uptime_diff;
56 + for (p = callout; p != NULL; p = p->c_next)
57 + p->c_time.tv_sec += new_diff - uptime_diff;
59 + uptime_diff = new_diff;
63 * timeout - Schedule a timeout.
64 @@ -1334,6 +1367,8 @@ calltimeout()
70 while (callout != NULL) {
73 @@ -1361,6 +1396,8 @@ timeleft(tvp)
80 gettimeofday(&timenow, NULL);
81 tvp->tv_sec = callout->c_time.tv_sec - timenow.tv_sec;