diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2006-01-05 11:32:32 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2006-01-05 11:32:32 +0100 |
commit | bc269db4fc4319885f7629dc607d86c8b6b1d98d (patch) | |
tree | 2358862ea2b0a34fc63d43672454ff54ab05e988 | |
parent | 645170db0ac1774882b18e7506108c2222d7fcbb (diff) | |
download | vdr-bc269db4fc4319885f7629dc607d86c8b6b1d98d.tar.gz vdr-bc269db4fc4319885f7629dc607d86c8b6b1d98d.tar.bz2 |
Disabled the use of fadvise in cUnbufferedFile because there have been several reports that it causes more problems than it solves
-rw-r--r-- | CONTRIBUTORS | 4 | ||||
-rw-r--r-- | HISTORY | 7 | ||||
-rw-r--r-- | tools.c | 14 |
3 files changed, 23 insertions, 2 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index f35a50b5..789a39f5 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -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 @@ -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. @@ -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; |