From ddda0dc539979f3c4ddfdbae48042d840bdf05e0 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Tue, 25 Mar 2008 20:08:40 +0000 Subject: [PATCH] Update to advise Linux about FS caching --- recplayer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/recplayer.c b/recplayer.c index 6647589..3c550ef 100644 --- a/recplayer.c +++ b/recplayer.c @@ -20,6 +20,9 @@ #include "recplayer.h" +#define _XOPEN_SOURCE 600 +#include + RecPlayer::RecPlayer(cRecording* rec) { log = Log::getInstance(); @@ -163,7 +166,10 @@ unsigned long RecPlayer::getBlock(unsigned char* buffer, ULLONG position, unsign filePosition = currentPosition - segments[segmentNumber]->start; fseek(file, filePosition, SEEK_SET); if (fread(&buffer[got], getFromThisSegment, 1, file) != 1) return 0; // umm, big problem. - + + // Tell linux not to bother keeping the data in the FS cache + posix_fadvise(file->_fileno, filePosition, getFromThisSegment, POSIX_FADV_DONTNEED); + got += getFromThisSegment; currentPosition += getFromThisSegment; yetToGet -= getFromThisSegment; -- 2.39.5