From b4d1358c50fb095eb7a2daf494780ce193ffb453 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 24 Nov 2002 16:08:06 +0100 Subject: [PATCH] Improved deleting stale lock files --- CONTRIBUTORS | 1 + HISTORY | 4 ++++ tools.c | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 83af710c..d8ecbf35 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -435,6 +435,7 @@ Oliver Endriss for reporting a bug in the EPG scanner, which broke 'Transfer Mode' as soon as it kicked in for providing examples for 'diseqc.conf' + for improving deleting stale lock files Reinhard Walter Buchner for adding some satellites to 'sources.conf' diff --git a/HISTORY b/HISTORY index c3eb6a8e..4d215082 100644 --- a/HISTORY +++ b/HISTORY @@ -1808,3 +1808,7 @@ Video Disk Recorder Revision History - Made some channels unique in 'channels.conf.terr' using the new RID. - Extended the '-l' option to allow logging to LOG_LOCALn (n=0..7) by writing, for instance, '-l 3.7' (suggested by Jürgen Schmidt). +- Now deleting stale lock files if they have a time stamp that is outside the window + 'now +/- LOCKFILESTALETIME'. This improves things in cases where the system time + makes far jumps, so that a lock file might end up with a time stamp that lies + in the distant future (thanks to Oliver Endriss). diff --git a/tools.c b/tools.c index a6bc80b1..c34a6217 100644 --- a/tools.c +++ b/tools.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 1.74 2002/11/24 15:47:02 kls Exp $ + * $Id: tools.c 1.75 2002/11/24 16:04:57 kls Exp $ */ #include "tools.h" @@ -722,7 +722,7 @@ bool cLockFile::Lock(int WaitSeconds) if (errno == EEXIST) { struct stat fs; if (stat(fileName, &fs) == 0) { - if (time(NULL) - fs.st_mtime > LOCKFILESTALETIME) { + if (abs(time(NULL)) - fs.st_mtime > LOCKFILESTALETIME) { esyslog("ERROR: removing stale lock file '%s'", fileName); if (remove(fileName) < 0) { LOG_ERROR_STR(fileName);