source:
freewrt/package/ppp/patches/209-compensate_time_change.patch@
6fc4520e
| Last change on this file since 6fc4520e was 475ad56, checked in by , 20 years ago | |
|---|---|
|
|
| File size: 1.9 KB | |
-
pppd/main.c
diff -urN ppp.old/pppd/main.c ppp.dev/pppd/main.c
old new 90 90 #include <sys/socket.h> 91 91 #include <netinet/in.h> 92 92 #include <arpa/inet.h> 93 #include <sys/sysinfo.h> 93 94 94 95 #include "pppd.h" 95 96 #include "magic.h" … … 227 228 228 229 /* Prototypes for procedures local to this file. */ 229 230 231 static void check_time(void); 230 232 static void setup_signals __P((void)); 231 233 static void create_pidfile __P((int pid)); 232 234 static void create_linkpidfile __P((int pid)); … … 531 533 info("Starting link"); 532 534 } 533 535 536 check_time(); 534 537 gettimeofday(&start_time, NULL); 535 538 script_unsetenv("CONNECT_TIME"); 536 539 script_unsetenv("BYTES_SENT"); … … 1195 1198 1196 1199 static struct callout *callout = NULL; /* Callout list */ 1197 1200 static struct timeval timenow; /* Current time */ 1201 static long uptime_diff = 0; 1202 static int uptime_diff_set = 0; 1203 1204 static void check_time(void) 1205 { 1206 long new_diff; 1207 struct timeval t; 1208 struct sysinfo i; 1209 struct callout *p; 1210 1211 gettimeofday(&t, NULL); 1212 sysinfo(&i); 1213 new_diff = t.tv_sec - i.uptime; 1214 1215 if (!uptime_diff_set) { 1216 uptime_diff = new_diff; 1217 uptime_diff_set = 1; 1218 return; 1219 } 1220 1221 if ((new_diff - 5 > uptime_diff) || (new_diff + 5 < uptime_diff)) { 1222 /* system time has changed, update counters and timeouts */ 1223 info("System time change detected."); 1224 start_time.tv_sec += new_diff - uptime_diff; 1225 1226 for (p = callout; p != NULL; p = p->c_next) 1227 p->c_time.tv_sec += new_diff - uptime_diff; 1228 } 1229 uptime_diff = new_diff; 1230 } 1198 1231 1199 1232 /* 1200 1233 * timeout - Schedule a timeout. … … 1265 1298 { 1266 1299 struct callout *p; 1267 1300 1301 check_time(); 1302 1268 1303 while (callout != NULL) { 1269 1304 p = callout; 1270 1305 … … 1292 1327 { 1293 1328 if (callout == NULL) 1294 1329 return NULL; 1330 1331 check_time(); 1295 1332 1296 1333 gettimeofday(&timenow, NULL); 1297 1334 tvp->tv_sec = callout->c_time.tv_sec - timenow.tv_sec;
Note:
See TracBrowser
for help on using the repository browser.
