1
0
Fork 0
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:
Charles Kerr 2009-01-25 23:33:10 +00:00
parent 29661cf245
commit 00125c9726
2 changed files with 22 additions and 0 deletions

View file

@ -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

View file

@ -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;
}