diff --git a/libtransmission/bencode.c b/libtransmission/bencode.c index be87bb031..9338815ff 100644 --- a/libtransmission/bencode.c +++ b/libtransmission/bencode.c @@ -1660,17 +1660,6 @@ tr_mkstemp( char * template ) #endif } -/* portability wrapper for fsync(). */ -static void -tr_fsync( int fd ) -{ -#ifdef WIN32 - _commit( fd ); -#else - fsync( fd ); -#endif -} - int tr_bencToFile( const tr_benc * top, tr_fmt_mode mode, const char * filename ) { diff --git a/libtransmission/fdlimit.c b/libtransmission/fdlimit.c index 030355132..9eae214d6 100644 --- a/libtransmission/fdlimit.c +++ b/libtransmission/fdlimit.c @@ -180,6 +180,19 @@ preallocate_file_full( const char * filename, uint64_t length ) return success; } + +/* portability wrapper for fsync(). */ +int +tr_fsync( int fd ) +{ +#ifdef WIN32 + return _commit( fd ); +#else + return fsync( fd ); +#endif +} + + /* Like pread and pwrite, except that the position is undefined afterwards. And of course they are not thread-safe. */ @@ -295,7 +308,7 @@ tr_close_file( int fd ) * but it couldn't hurt... */ fcntl( fd, F_NOCACHE, 1 ); #endif - fsync( fd ); + tr_fsync( fd ); close( fd ); } diff --git a/libtransmission/fdlimit.h b/libtransmission/fdlimit.h index fe517dbf0..d03bf4b23 100644 --- a/libtransmission/fdlimit.h +++ b/libtransmission/fdlimit.h @@ -40,6 +40,8 @@ int tr_open_file_for_writing( const char * filename ); void tr_close_file( int fd ); +int tr_fsync(int fd); + ssize_t tr_pread(int fd, void *buf, size_t count, off_t offset); ssize_t tr_pwrite(int fd, const void *buf, size_t count, off_t offset); int tr_prefetch(int fd, off_t offset, size_t count);