]> granicus.if.org Git - transmission/commitdiff
(trunk libT) #3973 "JIT verification verifies fresh downloaded torrents" -- win32...
authorJordan Lee <jordan@transmissionbt.com>
Wed, 2 Feb 2011 23:19:54 +0000 (23:19 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Wed, 2 Feb 2011 23:19:54 +0000 (23:19 +0000)
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.

libtransmission/bencode.c
libtransmission/fdlimit.c
libtransmission/fdlimit.h

index be87bb03136871de07463d93acb77c7a219fcd39..9338815ff70af00153174e84ffab0b8291864f51 100644 (file)
@@ -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 )
 {
index 030355132f7df5f005f264dde9f1489e5f3ebffc..9eae214d60b31d656e85541cb758128e2a676c20 100644 (file)
@@ -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 );
 }
 
index fe517dbf0329d76bedf813fa8fcfb5fb0ee0f864..d03bf4b2390d38771b47bb702ff57022d9dbf4e2 100644 (file)
@@ -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);