Read-ahead only makes sense for seekable file descriptors

(You can't read ahead a pipe)
This commit is contained in:
Rémi Denis-Courmont 2010-01-16 11:38:17 +02:00
parent 063a3bc887
commit 6bd7922ece
1 changed files with 10 additions and 11 deletions

View File

@ -249,6 +249,16 @@ static int Open( vlc_object_t *p_this )
posix_fadvise (fd, 0, 4096, POSIX_FADV_WILLNEED);
/* In most cases, we only read the file once. */
posix_fadvise (fd, 0, 0, POSIX_FADV_NOREUSE);
#if defined(HAVE_FCNTL)
/* We'd rather use any available memory for reading ahead
* than for caching what we've already seen/heard */
# if defined(F_RDAHEAD)
fcntl (fd, F_RDAHEAD, 1);
# endif
# if defined(F_NOCACHE)
fcntl (fd, F_NOCACHE, 1);
# endif
#endif
}
return VLC_SUCCESS;
@ -416,16 +426,5 @@ static int open_file (access_t *p_access, const char *path)
return -1;
}
#if defined(HAVE_FCNTL)
/* We'd rather use any available memory for reading ahead
* than for caching what we've already seen/heard */
# if defined(F_RDAHEAD)
fcntl (fd, F_RDAHEAD, 1);
# endif
# if defined(F_NOCACHE)
fcntl (fd, F_NOCACHE, 1);
# endif
#endif
return fd;
}