summaryrefslogtreecommitdiff
path: root/recording.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2005-12-28 12:21:57 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2005-12-28 12:21:57 +0100
commitfbddcb2fd69fc44e2eed62285b794cde92da5840 (patch)
tree23848b23f8c4ff108cff4de06c7cc2ef92b16815 /recording.c
parent967d9b0b03c8937ff766a6c8f5c9b621d2529391 (diff)
downloadvdr-fbddcb2fd69fc44e2eed62285b794cde92da5840.tar.gz
vdr-fbddcb2fd69fc44e2eed62285b794cde92da5840.tar.bz2
Removing deleted recordings is now done in a separate thread
Diffstat (limited to 'recording.c')
-rw-r--r--recording.c59
1 files changed, 45 insertions, 14 deletions
diff --git a/recording.c b/recording.c
index 3ab83ecf..b2718c9a 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.129 2005/12/18 13:38:30 kls Exp $
+ * $Id: recording.c 1.130 2005/12/28 12:19:16 kls Exp $
*/
#include "recording.h"
@@ -62,26 +62,57 @@ bool VfatFileSystem = false;
cRecordings DeletedRecordings(true);
-void RemoveDeletedRecordings(void)
+// --- cRemoveDeletedRecordingsThread ----------------------------------------
+
+class cRemoveDeletedRecordingsThread : public cThread {
+protected:
+ virtual void Action(void);
+public:
+ cRemoveDeletedRecordingsThread(void);
+ };
+
+cRemoveDeletedRecordingsThread::cRemoveDeletedRecordingsThread(void)
+:cThread("remove deleted recordings")
{
- static time_t LastRemoveCheck = 0;
- if (time(NULL) - LastRemoveCheck > REMOVECHECKDELTA) {
+}
+
+void cRemoveDeletedRecordingsThread::Action(void)
+{
+ // Make sure only one instance of VDR does this:
+ cLockFile LockFile(VideoDirectory);
+ if (LockFile.Lock()) {
cThreadLock DeletedRecordingsLock(&DeletedRecordings);
for (cRecording *r = DeletedRecordings.First(); r; ) {
if (r->deleted && time(NULL) - r->deleted > DELETEDLIFETIME) {
- // Make sure only one instance of VDR does this:
- cLockFile LockFile(VideoDirectory);
- if (LockFile.Lock()) {
- cRecording *next = DeletedRecordings.Next(r);
- r->Remove();
- DeletedRecordings.Del(r);
- r = next;
- RemoveEmptyVideoDirectories();
- continue;
- }
+ cRecording *next = DeletedRecordings.Next(r);
+ r->Remove();
+ DeletedRecordings.Del(r);
+ r = next;
+ RemoveEmptyVideoDirectories();
+ continue;
}
r = DeletedRecordings.Next(r);
}
+ }
+}
+
+static cRemoveDeletedRecordingsThread RemoveDeletedRecordingsThread;
+
+// ---
+
+void RemoveDeletedRecordings(void)
+{
+ static time_t LastRemoveCheck = 0;
+ if (time(NULL) - LastRemoveCheck > REMOVECHECKDELTA) {
+ if (!RemoveDeletedRecordingsThread.Active()) {
+ cThreadLock DeletedRecordingsLock(&DeletedRecordings);
+ for (cRecording *r = DeletedRecordings.First(); r; r = DeletedRecordings.Next(r)) {
+ if (r->deleted && time(NULL) - r->deleted > DELETEDLIFETIME) {
+ RemoveDeletedRecordingsThread.Start();
+ break;
+ }
+ }
+ }
LastRemoveCheck = time(NULL);
}
}