summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2006-01-05 11:32:32 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2006-01-05 11:32:32 +0100
commitbc269db4fc4319885f7629dc607d86c8b6b1d98d (patch)
tree2358862ea2b0a34fc63d43672454ff54ab05e988 /tools.c
parent645170db0ac1774882b18e7506108c2222d7fcbb (diff)
downloadvdr-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
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/tools.c b/tools.c
index 4bcf110f..546f60a1 100644
--- a/tools.c
+++ b/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;