diff options
-rw-r--r-- | HISTORY | 4 | ||||
-rw-r--r-- | config.c | 22 | ||||
-rw-r--r-- | eit.c | 20 | ||||
-rw-r--r-- | recording.c | 11 | ||||
-rw-r--r-- | tools.c | 5 |
5 files changed, 40 insertions, 22 deletions
@@ -787,7 +787,7 @@ Video Disk Recorder Revision History - Made the volume, mute and power keys work when a menu is active, too (thanks to Matthias Weingart). -2001-10-07: Version 0.97 +2001-10-19: Version 0.97 - Implemented a lock file to prevent more than one instance of VDR from removing files from the video directory at the same time. @@ -817,3 +817,5 @@ Video Disk Recorder Revision History (where these are assumed to be single line texts) and would have to be specially handled in the 'epg.data' file and the LSTE command in SVDRP. - Mapping ` ("backtick") characters in EPG texts to ' (single quote). +- Fixed timers starting and ending at unexpected times. 'localtime()' was not + thread safe, now using localtime_r(). @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.c 1.74 2001/09/30 11:28:47 kls Exp $ + * $Id: config.c 1.75 2001/10/19 13:14:09 kls Exp $ */ #include "config.h" @@ -324,7 +324,8 @@ cTimer::cTimer(bool Instant) cChannel *ch = Channels.GetByNumber(cDvbApi::CurrentChannel()); channel = ch ? ch->number : 0; time_t t = time(NULL); - struct tm *now = localtime(&t); + struct tm tm_r; + struct tm *now = localtime_r(&t, &tm_r); day = now->tm_mday; start = now->tm_hour * 100 + now->tm_min; stop = start + 200; // "instant recording" records 2 hours by default @@ -349,10 +350,11 @@ cTimer::cTimer(const cEventInfo *EventInfo) time_t tstart = EventInfo->GetTime(); time_t tstop = tstart + EventInfo->GetDuration() + Setup.MarginStop * 60; tstart -= Setup.MarginStart * 60; - struct tm *time = localtime(&tstart); + struct tm tm_r; + struct tm *time = localtime_r(&tstart, &tm_r); day = time->tm_mday; start = time->tm_hour * 100 + time->tm_min; - time = localtime(&tstop); + time = localtime_r(&tstop, &tm_r); stop = time->tm_hour * 100 + time->tm_min; if (stop >= 2400) stop -= 2400; @@ -497,12 +499,14 @@ bool cTimer::IsSingleEvent(void) int cTimer::GetMDay(time_t t) { - return localtime(&t)->tm_mday; + struct tm tm_r; + return localtime_r(&t, &tm_r)->tm_mday; } int cTimer::GetWDay(time_t t) { - int weekday = localtime(&t)->tm_wday; + struct tm tm_r; + int weekday = localtime_r(&t, &tm_r)->tm_wday; return weekday == 0 ? 6 : weekday - 1; // we start with monday==0! } @@ -513,7 +517,8 @@ bool cTimer::DayMatches(time_t t) time_t cTimer::IncDay(time_t t, int Days) { - tm tm = *localtime(&t); + struct tm tm_r; + tm tm = *localtime_r(&t, &tm_r); tm.tm_mday += Days; // now tm_mday may be out of its valid range int h = tm.tm_hour; // save original hour to compensate for DST change t = mktime(&tm); // normalize all values @@ -523,7 +528,8 @@ time_t cTimer::IncDay(time_t t, int Days) time_t cTimer::SetTime(time_t t, int SecondsFromMidnight) { - tm tm = *localtime(&t); + struct tm tm_r; + tm tm = *localtime_r(&t, &tm_r); tm.tm_hour = SecondsFromMidnight / 3600; tm.tm_min = (SecondsFromMidnight % 3600) / 60; tm.tm_sec = SecondsFromMidnight % 60; @@ -16,7 +16,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: eit.c 1.27 2001/10/07 14:35:25 kls Exp $ + * $Id: eit.c 1.28 2001/10/19 13:13:25 kls Exp $ ***************************************************************************/ #include "eit.h" @@ -126,7 +126,8 @@ bool cMJD::SetSystemTime() struct tm *ptm; time_t loctim; - ptm = localtime(&mjdtime); + struct tm tm_r; + ptm = localtime_r(&mjdtime, &tm_r); loctim = time(NULL); if (abs(mjdtime - loctim) > 2) @@ -240,7 +241,8 @@ const char * cEventInfo::GetDate() const { static char szDate[25]; - strftime(szDate, sizeof(szDate), "%d.%m.%Y", localtime(&tTime)); + struct tm tm_r; + strftime(szDate, sizeof(szDate), "%d.%m.%Y", localtime_r(&tTime, &tm_r)); return szDate; } @@ -249,7 +251,8 @@ const char * cEventInfo::GetTimeString() const { static char szTime[25]; - strftime(szTime, sizeof(szTime), "%R", localtime(&tTime)); + struct tm tm_r; + strftime(szTime, sizeof(szTime), "%R", localtime_r(&tTime, &tm_r)); return szTime; } @@ -259,7 +262,8 @@ const char * cEventInfo::GetEndTimeString() const static char szEndTime[25]; time_t tEndTime = tTime + lDuration; - strftime(szEndTime, sizeof(szEndTime), "%R", localtime(&tEndTime)); + struct tm tm_r; + strftime(szEndTime, sizeof(szEndTime), "%R", localtime_r(&tEndTime, &tm_r)); return szEndTime; } @@ -467,7 +471,8 @@ void cEventInfo::FixEpgBugs(void) // correctly on the ASTRA satellite system. if (uServiceID == 898 // Pro-7 || uServiceID == 899) { // Kabel 1 - tm *t = localtime(&tTime); + struct tm tm_r; + tm *t = localtime_r(&tTime, &tm_r); if (t->tm_hour * 3600 + t->tm_min * 60 + t->tm_sec <= 6 * 3600) tTime += 24 * 3600; } @@ -886,7 +891,8 @@ void cSIProcessor::Action() if (masterSIProcessor) { time_t now = time(NULL); - struct tm *ptm = localtime(&now); + struct tm tm_r; + struct tm *ptm = localtime_r(&now, &tm_r); if (now - lastCleanup > 3600 && ptm->tm_hour == 5) { LOCK_THREAD; diff --git a/recording.c b/recording.c index 403bbb6b..2f4e1d26 100644 --- a/recording.c +++ b/recording.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.c 1.40 2001/10/07 15:13:34 kls Exp $ + * $Id: recording.c 1.41 2001/10/19 13:12:17 kls Exp $ */ #include "recording.h" @@ -252,7 +252,8 @@ cRecording::cRecording(const char *FileName) summary = NULL; if (p) { time_t now = time(NULL); - struct tm t = *localtime(&now); // this initializes the time zone in 't' + struct tm tm_r; + struct tm t = *localtime_r(&now, &tm_r); // this initializes the time zone in 't' t.tm_isdst = -1; // makes sure mktime() will determine the correct dst setting if (7 == sscanf(p + 1, DATAFORMAT, &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min, &priority, &lifetime)) { t.tm_year -= 1900; @@ -350,7 +351,8 @@ bool cRecording::operator< (const cListObject &ListObject) const char *cRecording::FileName(void) { if (!fileName) { - struct tm *t = localtime(&start); + struct tm tm_r; + struct tm *t = localtime_r(&start, &tm_r); ExchangeChars(name, true); asprintf(&fileName, NAMEFORMAT, VideoDirectory, name, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, priority, lifetime); ExchangeChars(name, false); @@ -368,7 +370,8 @@ const char *cRecording::Title(char Delimiter, bool NewIndicator) } delete titleBuffer; titleBuffer = NULL; - struct tm *t = localtime(&start); + struct tm tm_r; + struct tm *t = localtime_r(&start, &tm_r); asprintf(&titleBuffer, "%02d.%02d%c%02d:%02d%c%c%s", t->tm_mday, t->tm_mon + 1, @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 1.49 2001/10/07 15:13:45 kls Exp $ + * $Id: tools.c 1.50 2001/10/19 13:12:45 kls Exp $ */ #include "tools.h" @@ -416,7 +416,8 @@ const char *DayDateTime(time_t t) static char buffer[32]; if (t == 0) time(&t); - tm *tm = localtime(&t); + struct tm tm_r; + tm *tm = localtime_r(&t, &tm_r); int weekday = tm->tm_wday == 0 ? 6 : tm->tm_wday - 1; // we start with monday==0! const char *day = tr("MonTueWedThuFriSatSun"); day += weekday * 3; |