1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Disabled the use of fadvise in cUnbufferedFile because there have been several reports that it causes more problems than it solves

This commit is contained in:
Klaus Schmidinger 2006-01-05 11:32:32 +01:00
parent 645170db0a
commit bc269db4fc
3 changed files with 23 additions and 2 deletions

View File

@ -1610,3 +1610,7 @@ Thiemo Gehrke <tgehrke@reel-multimedia.com>
Gavin Hamill <gdh@acentral.co.uk>
for reporting a missing #include "thread.h" in dvbspu.c
Petri Hintukainen <Petri.Hintukainen@hut.fi>
for suggesting to disable the use of "fadvise" in cUnbufferedFile because there
have been several reports that it causes more problems than it solves

View File

@ -3963,7 +3963,7 @@ Video Disk Recorder Revision History
commands may now be executed at any time, and the message will be displayed
(no more "pending message").
2006-01-04: Version 1.3.38
2006-01-05: Version 1.3.38
- Fixed handling second audio and Dolby Digital PIDs for encrypted channels
(was broken in version 1.3.37).
@ -4091,3 +4091,8 @@ Video Disk Recorder Revision History
- Removed an obsolete "Summary" text from i18n.c and preceded all key definition
texts with "Key$" to avoid duplicates (reported by Lucian Muresan).
- Added missing #include "thread.h" to dvbspu.c (reported by Gavin Hamill).
- Disabled the use of "fadvise" in cUnbufferedFile because there have been
several reports that it causes more problems than it solves (suggested by
Petri Hintukainen). If you want to use "fadvise", you can activate the line
//#define USE_FADVISE
in tools.c.

14
tools.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: tools.c 1.107 2005/12/29 16:02:37 kls Exp $
* $Id: tools.c 1.108 2006/01/05 10:41:18 kls Exp $
*/
#include "tools.h"
@ -1040,6 +1040,8 @@ bool cSafeFile::Close(void)
// --- cUnbufferedFile -------------------------------------------------------
//#define USE_FADVISE
#define READ_AHEAD MEGABYTE(2)
#define WRITE_BUFFER MEGABYTE(10)
@ -1064,6 +1066,7 @@ int cUnbufferedFile::Open(const char *FileName, int Flags, mode_t Mode)
int cUnbufferedFile::Close(void)
{
#ifdef USE_FADVISE
if (fd >= 0) {
if (ahead > end)
end = ahead;
@ -1076,6 +1079,7 @@ int cUnbufferedFile::Close(void)
begin = end = ahead = -1;
written = 0;
}
#endif
int OldFd = fd;
fd = -1;
return close(OldFd);
@ -1091,6 +1095,7 @@ off_t cUnbufferedFile::Seek(off_t Offset, int Whence)
ssize_t cUnbufferedFile::Read(void *Data, size_t Size)
{
if (fd >= 0) {
#ifdef USE_FADVISE
off_t pos = lseek(fd, 0, SEEK_CUR);
// jump forward - adjust end position
if (pos > end)
@ -1104,7 +1109,9 @@ ssize_t cUnbufferedFile::Read(void *Data, size_t Size)
if (begin >= 0 && end > begin)
posix_fadvise(fd, begin - KILOBYTE(200), end - begin + KILOBYTE(200), POSIX_FADV_DONTNEED);//XXX macros/parameters???
begin = pos;
#endif
ssize_t bytesRead = safe_read(fd, Data, Size);
#ifdef USE_FADVISE
if (bytesRead > 0) {
pos += bytesRead;
end = pos;
@ -1117,6 +1124,7 @@ ssize_t cUnbufferedFile::Read(void *Data, size_t Size)
}
else
end = pos;
#endif
return bytesRead;
}
return -1;
@ -1125,8 +1133,11 @@ ssize_t cUnbufferedFile::Read(void *Data, size_t Size)
ssize_t cUnbufferedFile::Write(const void *Data, size_t Size)
{
if (fd >=0) {
#ifdef USE_FADVISE
off_t pos = lseek(fd, 0, SEEK_CUR);
#endif
ssize_t bytesWritten = safe_write(fd, Data, Size);
#ifdef USE_FADVISE
if (bytesWritten >= 0) {
written += bytesWritten;
if (begin >= 0) {
@ -1146,6 +1157,7 @@ ssize_t cUnbufferedFile::Write(const void *Data, size_t Size)
written = 0;
}
}
#endif
return bytesWritten;
}
return -1;