(trunk libT) #3973 "JIT verification verifies fresh downloaded torrents" -- win32 portability fix for r11813.
fsync() doesn't exist on Windows. bencode had a private function, tr_fsync(), that is a portability wrapper around fsync() on *nix and _commit() on win32. Make this function package-visible, rather than private, so fdlimit.c can use it too.
This commit is contained in:
parent
9d3a97f3ed
commit
4bf6f0ac40
|
@ -1660,17 +1660,6 @@ tr_mkstemp( char * template )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* portability wrapper for fsync(). */
|
|
||||||
static void
|
|
||||||
tr_fsync( int fd )
|
|
||||||
{
|
|
||||||
#ifdef WIN32
|
|
||||||
_commit( fd );
|
|
||||||
#else
|
|
||||||
fsync( fd );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
tr_bencToFile( const tr_benc * top, tr_fmt_mode mode, const char * filename )
|
tr_bencToFile( const tr_benc * top, tr_fmt_mode mode, const char * filename )
|
||||||
{
|
{
|
||||||
|
|
|
@ -180,6 +180,19 @@ preallocate_file_full( const char * filename, uint64_t length )
|
||||||
return success;
|
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.
|
/* Like pread and pwrite, except that the position is undefined afterwards.
|
||||||
And of course they are not thread-safe. */
|
And of course they are not thread-safe. */
|
||||||
|
|
||||||
|
@ -295,7 +308,7 @@ tr_close_file( int fd )
|
||||||
* but it couldn't hurt... */
|
* but it couldn't hurt... */
|
||||||
fcntl( fd, F_NOCACHE, 1 );
|
fcntl( fd, F_NOCACHE, 1 );
|
||||||
#endif
|
#endif
|
||||||
fsync( fd );
|
tr_fsync( fd );
|
||||||
close( fd );
|
close( fd );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,8 @@ int tr_open_file_for_writing( const char * filename );
|
||||||
|
|
||||||
void tr_close_file( int fd );
|
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_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);
|
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);
|
int tr_prefetch(int fd, off_t offset, size_t count);
|
||||||
|
|
Loading…
Reference in New Issue