source: freewrt/package/ppp/patches/209-compensate_time_change.patch@ 6fc4520e

freewrt_1_0 freewrt_2_0
Last change on this file since 6fc4520e was 475ad56, checked in by Waldemar Brodkorb <wbx@…>, 20 years ago

add OpenWrt trunk revision 3830.

git-svn-id: svn://www.freewrt.org/trunk/freewrt@1 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 1.9 KB
  • pppd/main.c

    diff -urN ppp.old/pppd/main.c ppp.dev/pppd/main.c
    old new  
    9090#include <sys/socket.h>
    9191#include <netinet/in.h>
    9292#include <arpa/inet.h>
     93#include <sys/sysinfo.h>
    9394
    9495#include "pppd.h"
    9596#include "magic.h"
     
    227228
    228229/* Prototypes for procedures local to this file. */
    229230
     231static void check_time(void);
    230232static void setup_signals __P((void));
    231233static void create_pidfile __P((int pid));
    232234static void create_linkpidfile __P((int pid));
     
    531533            info("Starting link");
    532534        }
    533535
     536        check_time();
    534537        gettimeofday(&start_time, NULL);
    535538        script_unsetenv("CONNECT_TIME");
    536539        script_unsetenv("BYTES_SENT");
     
    11951198
    11961199static struct callout *callout = NULL;  /* Callout list */
    11971200static struct timeval timenow;          /* Current time */
     1201static long uptime_diff = 0;
     1202static int uptime_diff_set = 0;
     1203
     1204static 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}
    11981231
    11991232/*
    12001233 * timeout - Schedule a timeout.
     
    12651298{
    12661299    struct callout *p;
    12671300
     1301        check_time();
     1302       
    12681303    while (callout != NULL) {
    12691304        p = callout;
    12701305
     
    12921327{
    12931328    if (callout == NULL)
    12941329        return NULL;
     1330       
     1331        check_time();
    12951332
    12961333    gettimeofday(&timenow, NULL);
    12971334    tvp->tv_sec = callout->c_time.tv_sec - timenow.tv_sec;
Note: See TracBrowser for help on using the repository browser.