summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2009-05-31 11:47:05 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2009-05-31 11:47:05 +0200
commit81cc592c336b45b32086cfeeec2495e0f7f2ded2 (patch)
tree15a09c17f66f8dd9dade5ff658eb4439d3207ecd /tools.c
parent3de4811a424e984a1dfa271a3be5f4137c935bc1 (diff)
downloadvdr-81cc592c336b45b32086cfeeec2495e0f7f2ded2.tar.gz
vdr-81cc592c336b45b32086cfeeec2495e0f7f2ded2.tar.bz2
Fixed calling close(-1) in cUnbufferedFile::Close()
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/tools.c b/tools.c
index f49206f0..9ef61f57 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 2.2 2009/01/16 14:29:08 kls Exp $
+ * $Id: tools.c 2.3 2009/05/31 11:43:24 kls Exp $
*/
#include "tools.h"
@@ -1473,16 +1473,18 @@ int cUnbufferedFile::Open(const char *FileName, int Flags, mode_t Mode)
int cUnbufferedFile::Close(void)
{
-#ifdef USE_FADVISE
if (fd >= 0) {
+#ifdef USE_FADVISE
if (totwritten) // if we wrote anything make sure the data has hit the disk before
fdatasync(fd); // calling fadvise, as this is our last chance to un-cache it.
posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
- }
#endif
- int OldFd = fd;
- fd = -1;
- return close(OldFd);
+ int OldFd = fd;
+ fd = -1;
+ return close(OldFd);
+ }
+ errno = EBADF;
+ return -1;
}
// When replaying and going e.g. FF->PLAY the position jumps back 2..8M