remove obseleted package
[openwrt.git] / package / ppp / patches / 209-compensate_time_change.patch
1 Index: ppp-2.4.3/pppd/main.c
2 ===================================================================
3 --- ppp-2.4.3.orig/pppd/main.c 2007-06-04 13:22:13.340827168 +0200
4 +++ ppp-2.4.3/pppd/main.c 2007-06-04 13:22:13.755764088 +0200
5 @@ -90,6 +90,7 @@
6 #include <sys/socket.h>
7 #include <netinet/in.h>
8 #include <arpa/inet.h>
9 +#include <sys/sysinfo.h>
10
11 #include "pppd.h"
12 #include "magic.h"
13 @@ -227,6 +228,7 @@
14
15 /* Prototypes for procedures local to this file. */
16
17 +static void check_time(void);
18 static void setup_signals __P((void));
19 static void create_pidfile __P((int pid));
20 static void create_linkpidfile __P((int pid));
21 @@ -531,6 +533,7 @@
22 info("Starting link");
23 }
24
25 + check_time();
26 gettimeofday(&start_time, NULL);
27 script_unsetenv("CONNECT_TIME");
28 script_unsetenv("BYTES_SENT");
29 @@ -1195,6 +1198,36 @@
30
31 static struct callout *callout = NULL; /* Callout list */
32 static struct timeval timenow; /* Current time */
33 +static long uptime_diff = 0;
34 +static int uptime_diff_set = 0;
35 +
36 +static void check_time(void)
37 +{
38 + long new_diff;
39 + struct timeval t;
40 + struct sysinfo i;
41 + struct callout *p;
42 +
43 + gettimeofday(&t, NULL);
44 + sysinfo(&i);
45 + new_diff = t.tv_sec - i.uptime;
46 +
47 + if (!uptime_diff_set) {
48 + uptime_diff = new_diff;
49 + uptime_diff_set = 1;
50 + return;
51 + }
52 +
53 + if ((new_diff - 5 > uptime_diff) || (new_diff + 5 < uptime_diff)) {
54 + /* system time has changed, update counters and timeouts */
55 + info("System time change detected.");
56 + start_time.tv_sec += new_diff - uptime_diff;
57 +
58 + for (p = callout; p != NULL; p = p->c_next)
59 + p->c_time.tv_sec += new_diff - uptime_diff;
60 + }
61 + uptime_diff = new_diff;
62 +}
63
64 /*
65 * timeout - Schedule a timeout.
66 @@ -1265,6 +1298,8 @@
67 {
68 struct callout *p;
69
70 + check_time();
71 +
72 while (callout != NULL) {
73 p = callout;
74
75 @@ -1292,6 +1327,8 @@
76 {
77 if (callout == NULL)
78 return NULL;
79 +
80 + check_time();
81
82 gettimeofday(&timenow, NULL);
83 tvp->tv_sec = callout->c_time.tv_sec - timenow.tv_sec;
This page took 0.045054 seconds and 5 git commands to generate.