summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2013-12-25 10:57:36 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2013-12-25 10:57:36 +0100
commit1045069fee38d6ca05fa02d7faf6a587e6054ec9 (patch)
tree71ef951e3eba5315d4c3a5f8210cb560887a8748
parentcca9d858a7db91f6d73e19d588732e789dc10b4f (diff)
downloadvdr-1045069fee38d6ca05fa02d7faf6a587e6054ec9.tar.gz
vdr-1045069fee38d6ca05fa02d7faf6a587e6054ec9.tar.bz2
Fixed a possible crash if the recordings list is updated externally while the Recordings menu is open
-rw-r--r--CONTRIBUTORS2
-rw-r--r--HISTORY4
-rw-r--r--recording.c58
-rw-r--r--recording.h8
-rw-r--r--vdr.c3
5 files changed, 56 insertions, 19 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 219d4c45..52ec1623 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -2851,6 +2851,8 @@ Lars Hanisch <dvb@flensrocker.de>
used
for making the LIRC remote control connect to the socket even if it doesn't yet exist
when VDR is started
+ for reporting a possible crash if the recordings list is updated externally while the
+ Recordings menu is open
Alex Lasnier <alex@fepg.org>
for adding tuning support for ATSC devices
diff --git a/HISTORY b/HISTORY
index a13f195b..7a770cf9 100644
--- a/HISTORY
+++ b/HISTORY
@@ -7854,7 +7854,7 @@ Video Disk Recorder Revision History
the last replayed recording (if any) by pressing Ok repeatedly in the Recordings
menu.
-2013-11-16: Version 2.0.5
+2013-12-25: Version 2.0.5
- The LIRC remote control now connects to the socket even if it doesn't yet exist when
VDR is started (thanks to Lars Hanisch).
@@ -7862,3 +7862,5 @@ Video Disk Recorder Revision History
Marko Mäkelä).
- Fixed uninitialized item area coordinates in cSkinLCARSDisplayMenu (reported by
Marko Mäkelä).
+- Fixed a possible crash if the recordings list is updated externally while the
+ Recordings menu is open (reported by Lars Hanisch).
diff --git a/recording.c b/recording.c
index 8ea5b9e8..c1a00cf9 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 2.91.1.2 2013/08/21 13:58:35 kls Exp $
+ * $Id: recording.c 2.91.1.3 2013/12/25 10:55:32 kls Exp $
*/
#include "recording.h"
@@ -72,6 +72,7 @@ bool DirectoryEncoding = false;
int InstanceId = 0;
cRecordings DeletedRecordings(true);
+static cRecordings VanishedRecordings;
// --- cRemoveDeletedRecordingsThread ----------------------------------------
@@ -216,6 +217,14 @@ void AssertFreeDiskSpace(int Priority, bool Force)
}
}
+// --- Clear vanished recordings ---------------------------------------------
+
+void ClearVanishedRecordings(void)
+{
+ cThreadLock RecordingsLock(&Recordings); // yes, it *is* Recordings!
+ VanishedRecordings.Clear();
+}
+
// --- cResumeFile -----------------------------------------------------------
cResumeFile::cResumeFile(const char *FileName, bool IsPesRecording)
@@ -1233,6 +1242,7 @@ cRecordings::cRecordings(bool Deleted)
:cThread("video directory scanner")
{
deleted = Deleted;
+ initial = true;
lastUpdate = 0;
state = 0;
}
@@ -1264,8 +1274,9 @@ void cRecordings::Refresh(bool Foreground)
ScanVideoDir(VideoDirectory, Foreground);
}
-void cRecordings::ScanVideoDir(const char *DirName, bool Foreground, int LinkLevel)
+void cRecordings::ScanVideoDir(const char *DirName, bool Foreground, int LinkLevel, int DirLevel)
{
+ // Find any new recordings:
cReadDir d(DirName);
struct dirent *e;
while ((Foreground || Running()) && (e = d.Next()) != NULL) {
@@ -1284,25 +1295,41 @@ void cRecordings::ScanVideoDir(const char *DirName, bool Foreground, int LinkLev
}
if (S_ISDIR(st.st_mode)) {
if (endswith(buffer, deleted ? DELEXT : RECEXT)) {
- cRecording *r = new cRecording(buffer);
- if (r->Name()) {
- r->NumFrames(); // initializes the numFrames member
- r->FileSizeMB(); // initializes the fileSizeMB member
- if (deleted)
- r->deleted = time(NULL);
- Lock();
- Add(r);
- ChangeState();
- Unlock();
+ if (deleted || initial || !GetByName(buffer)) {
+ cRecording *r = new cRecording(buffer);
+ if (r->Name()) {
+ r->NumFrames(); // initializes the numFrames member
+ r->FileSizeMB(); // initializes the fileSizeMB member
+ if (deleted)
+ r->deleted = time(NULL);
+ Lock();
+ Add(r);
+ ChangeState();
+ Unlock();
+ }
+ else
+ delete r;
}
- else
- delete r;
}
else
- ScanVideoDir(buffer, Foreground, LinkLevel + Link);
+ ScanVideoDir(buffer, Foreground, LinkLevel + Link, DirLevel + 1);
}
}
}
+ // Handle any vanished recordings:
+ if (!deleted && !initial && DirLevel == 0) {
+ for (cRecording *recording = First(); recording; ) {
+ cRecording *r = recording;
+ recording = Next(recording);
+ if (access(r->FileName(), F_OK) != 0) {
+ Lock();
+ Del(r, false);
+ VanishedRecordings.Add(r);
+ ChangeState();
+ Unlock();
+ }
+ }
+ }
}
bool cRecordings::StateChanged(int &State)
@@ -1343,6 +1370,7 @@ bool cRecordings::Update(bool Wait)
cRecording *cRecordings::GetByName(const char *FileName)
{
if (FileName) {
+ LOCK_THREAD;
for (cRecording *recording = First(); recording; recording = Next(recording)) {
if (strcmp(recording->FileName(), FileName) == 0)
return recording;
diff --git a/recording.h b/recording.h
index ff3119da..66239ea8 100644
--- a/recording.h
+++ b/recording.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: recording.h 2.46 2013/03/04 14:01:23 kls Exp $
+ * $Id: recording.h 2.46.1.1 2013/12/25 10:54:05 kls Exp $
*/
#ifndef __RECORDING_H
@@ -26,6 +26,7 @@ extern bool DirectoryEncoding;
extern int InstanceId;
void RemoveDeletedRecordings(void);
+void ClearVanishedRecordings(void);
void AssertFreeDiskSpace(int Priority = 0, bool Force = false);
///< The special Priority value -1 means that we shall get rid of any
///< deleted recordings faster than normal (because we're cutting).
@@ -160,11 +161,12 @@ class cRecordings : public cList<cRecording>, public cThread {
private:
static char *updateFileName;
bool deleted;
+ bool initial;
time_t lastUpdate;
int state;
const char *UpdateFileName(void);
void Refresh(bool Foreground = false);
- void ScanVideoDir(const char *DirName, bool Foreground = false, int LinkLevel = 0);
+ void ScanVideoDir(const char *DirName, bool Foreground = false, int LinkLevel = 0, int DirLevel = 0);
protected:
void Action(void);
public:
@@ -199,6 +201,8 @@ public:
///< this value is unknown.
};
+/// Any access to Recordings that loops through the list of recordings
+/// needs to hold a thread lock on this object!
extern cRecordings Recordings;
extern cRecordings DeletedRecordings;
diff --git a/vdr.c b/vdr.c
index dceabbdf..952a2f9c 100644
--- a/vdr.c
+++ b/vdr.c
@@ -22,7 +22,7 @@
*
* The project's page is at http://www.tvdr.de
*
- * $Id: vdr.c 2.57.1.1 2013/10/16 09:46:36 kls Exp $
+ * $Id: vdr.c 2.57.1.2 2013/12/25 10:54:36 kls Exp $
*/
#include <getopt.h>
@@ -1360,6 +1360,7 @@ int main(int argc, char *argv[])
// Disk housekeeping:
RemoveDeletedRecordings();
+ ClearVanishedRecordings();
cSchedules::Cleanup();
// Plugins housekeeping:
PluginManager.Housekeeping();