mirror of
https://github.com/transmission/transmission
synced 2025-02-20 13:16:53 +00:00
(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
3 changed files with 16 additions and 12 deletions
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue