Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] back to the time jumps
high!
here is a small patch to eit.c (the patch is made against vdr-1.0.4, but
it should work for 1.1.13 after removing LOG_ERR and LOG_INFO.)
I don't have a dvb card here, so I couldn't try to make vdr, maybe it
doesn't even compile.
The patch replaces the call to stime by adjtime. adjtime speeds up or
slows down the system clock in order to make a gradual adjustment. This
ensures that the system clock is always monotonically increasing, which is
not true if using stime and caused so many problems.
Although there is again a philosophical question: probably it is better to
use stime (or settimeofday) if the difference is very large (say bigger
than 15 minutes?)
BTW: there are two variables tm_r and ptm in the original function, whose
reason is not clear to me. Are those just forgotten relicts or do I just
miss something?
====================================
--- eit.c.orig Thu Oct 17 15:24:29 2002
+++ eit.c Thu Oct 17 15:40:03 2002
@@ -34,6 +34,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
+#include <sys/time.h>
#include <unistd.h>
#include "config.h"
#include "libdtv/libdtv.h"
@@ -127,15 +128,22 @@
time_t loctim;
struct tm tm_r;
+
+ struct timeval delta;
+
ptm = localtime_r(&mjdtime, &tm_r);
- loctim = time(NULL);
+ loctim = time(NULL); /* system time in seconds since epoch */
- if (abs(mjdtime - loctim) > 2)
+ if (abs(mjdtime - loctim) > 0)
{
isyslog(LOG_INFO, "System Time = %s (%ld)\n", ctime(&loctim), loctim);
isyslog(LOG_INFO, "Local Time = %s (%ld)\n", ctime(&mjdtime), mjdtime);
+
+ delta.tv_sec = (long int)(mjdtime - loctim);
+ delta.tv_usec = 0;
+
- if (stime(&mjdtime) < 0)
+ if (adjtime(&delta,NULL) < 0)
- esyslog(LOG_ERR, "ERROR while setting system time: %m");
+ esyslog(LOG_ERR, "ERROR while adjusting system time: %m");
return true;
}
====================================
c ya
Sergei
--
--------------------------------------------------------------------
eMail: Sergei.Haller@math.uni-giessen.de
--------------------------------------------------------------------
Be careful of reading health books, you might die of a misprint.
-- Mark Twain
--
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe vdr" as subject.
Home |
Main Index |
Thread Index