mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
No longer waiting inside cIndexFile::CatchUp() to avoid shortly blocking replay at the end of a recording
This commit is contained in:
parent
c6f6e881f8
commit
a28e2ef5b5
2
HISTORY
2
HISTORY
@ -2170,3 +2170,5 @@ Video Disk Recorder Revision History
|
|||||||
Endriss for reporting this one).
|
Endriss for reporting this one).
|
||||||
- Fixed EPG bugfix statistics to avoid log entires for undefined channels (thanks
|
- Fixed EPG bugfix statistics to avoid log entires for undefined channels (thanks
|
||||||
to Lars Bläser for reporting this one).
|
to Lars Bläser for reporting this one).
|
||||||
|
- No longer waiting inside cIndexFile::CatchUp() to avoid shortly blocking replay
|
||||||
|
at the end of a recording.
|
||||||
|
90
recording.c
90
recording.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: recording.c 1.77 2003/05/11 13:09:08 kls Exp $
|
* $Id: recording.c 1.78 2003/05/18 15:17:45 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "recording.h"
|
#include "recording.h"
|
||||||
@ -764,9 +764,6 @@ void cRecordingUserCommand::InvokeCommand(const char *State, const char *Recordi
|
|||||||
|
|
||||||
#define INDEXFILESUFFIX "/index.vdr"
|
#define INDEXFILESUFFIX "/index.vdr"
|
||||||
|
|
||||||
// The maximum time to wait before giving up while catching up on an index file:
|
|
||||||
#define MAXINDEXCATCHUP 2 // seconds
|
|
||||||
|
|
||||||
// The minimum age of an index file for considering it no longer to be written:
|
// The minimum age of an index file for considering it no longer to be written:
|
||||||
#define MININDEXAGE 3600 // seconds
|
#define MININDEXAGE 3600 // seconds
|
||||||
|
|
||||||
@ -850,50 +847,47 @@ bool cIndexFile::CatchUp(int Index)
|
|||||||
{
|
{
|
||||||
// returns true unless something really goes wrong, so that 'index' becomes NULL
|
// returns true unless something really goes wrong, so that 'index' becomes NULL
|
||||||
if (index && f >= 0) {
|
if (index && f >= 0) {
|
||||||
for (int i = 0; i <= MAXINDEXCATCHUP && (Index < 0 || Index >= last); i++) {
|
if (Index < 0 || Index >= last) {
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if (fstat(f, &buf) == 0) {
|
if (fstat(f, &buf) == 0) {
|
||||||
if (time(NULL) - buf.st_mtime > MININDEXAGE) {
|
if (time(NULL) - buf.st_mtime > MININDEXAGE) {
|
||||||
// apparently the index file is not being written any more
|
// apparently the index file is not being written any more
|
||||||
close(f);
|
close(f);
|
||||||
f = -1;
|
f = -1;
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
int newLast = buf.st_size / sizeof(tIndex) - 1;
|
int newLast = buf.st_size / sizeof(tIndex) - 1;
|
||||||
if (newLast > last) {
|
if (newLast > last) {
|
||||||
if (size <= newLast) {
|
if (size <= newLast) {
|
||||||
size *= 2;
|
size *= 2;
|
||||||
if (size <= newLast)
|
if (size <= newLast)
|
||||||
size = newLast + 1;
|
size = newLast + 1;
|
||||||
}
|
}
|
||||||
index = (tIndex *)realloc(index, size * sizeof(tIndex));
|
index = (tIndex *)realloc(index, size * sizeof(tIndex));
|
||||||
if (index) {
|
if (index) {
|
||||||
int offset = (last + 1) * sizeof(tIndex);
|
int offset = (last + 1) * sizeof(tIndex);
|
||||||
int delta = (newLast - last) * sizeof(tIndex);
|
int delta = (newLast - last) * sizeof(tIndex);
|
||||||
if (lseek(f, offset, SEEK_SET) == offset) {
|
if (lseek(f, offset, SEEK_SET) == offset) {
|
||||||
if (safe_read(f, &index[last + 1], delta) != delta) {
|
if (safe_read(f, &index[last + 1], delta) != delta) {
|
||||||
esyslog("ERROR: can't read from index");
|
esyslog("ERROR: can't read from index");
|
||||||
free(index);
|
free(index);
|
||||||
index = NULL;
|
index = NULL;
|
||||||
close(f);
|
close(f);
|
||||||
f = -1;
|
f = -1;
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
last = newLast;
|
last = newLast;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LOG_ERROR_STR(fileName);
|
LOG_ERROR_STR(fileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
esyslog("ERROR: can't realloc() index");
|
esyslog("ERROR: can't realloc() index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LOG_ERROR_STR(fileName);
|
LOG_ERROR_STR(fileName);
|
||||||
if (Index < last)
|
}
|
||||||
break;
|
|
||||||
sleep(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return index != NULL;
|
return index != NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user