mirror of
https://github.com/transmission/transmission
synced 2025-02-07 15:04:13 +00:00
(trunk libT) add mac, linux, and win32 support for os-level hints that local data will be read in random order, to disable readahead buffering.
This commit is contained in:
parent
29661cf245
commit
00125c9726
2 changed files with 22 additions and 0 deletions
12
configure.ac
12
configure.ac
|
@ -96,6 +96,18 @@ AC_PATH_ZLIB
|
|||
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
|
||||
dnl ----------------------------------------------------------------------------
|
||||
dnl
|
||||
dnl posix_fadvise
|
||||
|
||||
dnl can posix_fadvise be used
|
||||
AC_CHECK_DECLS(posix_fadvise, [], [], [
|
||||
#define _XOPEN_SOURCE 600
|
||||
#include <fcntl.h>])
|
||||
AC_CHECK_FUNCS([posix_fadvise])
|
||||
|
||||
|
||||
dnl ----------------------------------------------------------------------------
|
||||
dnl
|
||||
dnl va_copy
|
||||
|
|
|
@ -231,6 +231,9 @@ TrOpenFile( int i,
|
|||
|
||||
/* open the file */
|
||||
flags = doWrite ? ( O_RDWR | O_CREAT ) : O_RDONLY;
|
||||
#ifdef O_RANDOM
|
||||
flags |= O_RANDOM
|
||||
#endif
|
||||
#ifdef O_LARGEFILE
|
||||
flags |= O_LARGEFILE;
|
||||
#endif
|
||||
|
@ -249,6 +252,13 @@ TrOpenFile( int i,
|
|||
if( doWrite && !alreadyExisted && ( preallocationMode == TR_PREALLOCATE_SPARSE ) )
|
||||
preallocateFileSparse( file->fd, desiredFileSize );
|
||||
|
||||
#if defined( SYS_DARWIN )
|
||||
fcntl( file->fd, F_NOCACHE, 1 );
|
||||
fcntl( file->fd, F_RDAHEAD, 0 );
|
||||
#elif defined( HAVE_POSIX_FADVISE )
|
||||
posix_fadvise( file->fd, 0, 0, POSIX_FADV_RANDOM );
|
||||
#endif
|
||||
|
||||
tr_free( filename );
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue