diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2005-08-07 13:52:29 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2005-08-07 13:52:29 +0200 |
commit | 5da7f10c3e6e16a610049cacb6561203b1f7b47a (patch) | |
tree | 8663af21f34652f9a5a76f2b4561ae23dbb78a0a /eit.c | |
parent | 1173d8d359ffdf43fc48073eeb640534cab0be89 (diff) | |
download | vdr-5da7f10c3e6e16a610049cacb6561203b1f7b47a.tar.gz vdr-5da7f10c3e6e16a610049cacb6561203b1f7b47a.tar.bz2 |
Fixed setting system time to avoid time jumps in case of faulty data
Diffstat (limited to 'eit.c')
-rw-r--r-- | eit.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -8,7 +8,7 @@ * Robert Schneider <Robert.Schneider@web.de> and Rolf Hakenes <hakenes@hippomi.de>. * Adapted to 'libsi' for VDR 1.3.0 by Marcel Wiesweg <marcel.wiesweg@gmx.de>. * - * $Id: eit.c 1.108 2005/06/11 15:31:21 kls Exp $ + * $Id: eit.c 1.109 2005/08/07 13:52:29 kls Exp $ */ #include "eit.h" @@ -252,11 +252,13 @@ cEIT::cEIT(cSchedules *Schedules, int Source, u_char Tid, const u_char *Data) class cTDT : public SI::TDT { private: static cMutex mutex; + static int lastDiff; public: cTDT(const u_char *Data); }; cMutex cTDT::mutex; +int cTDT::lastDiff = 0; cTDT::cTDT(const u_char *Data) :SI::TDT(Data, false) @@ -266,12 +268,16 @@ cTDT::cTDT(const u_char *Data) time_t sattim = getTime(); time_t loctim = time(NULL); - if (abs(sattim - loctim) > 2) { + int diff = abs(sattim - loctim); + if (diff > 2) { mutex.Lock(); - isyslog("System Time = %s (%ld)\n", *TimeToString(loctim), loctim); - isyslog("Local Time = %s (%ld)\n", *TimeToString(sattim), sattim); - if (stime(&sattim) < 0) - esyslog("ERROR while setting system time: %m"); + if (abs(diff - lastDiff) < 3) { + isyslog("System Time = %s (%ld)\n", *TimeToString(loctim), loctim); + isyslog("Local Time = %s (%ld)\n", *TimeToString(sattim), sattim); + if (stime(&sattim) < 0) + esyslog("ERROR while setting system time: %m"); + } + lastDiff = diff; mutex.Unlock(); } } |