r11813 fixed the timestamp issue by fsync()ing files before close()ing them in tr_close_file(). This causes a little overhead as even read-only files cause a sync as their atimes are modified. Instead, we should call fsync() further back in the call chain in tr_fdFileClose() so that we can know to only sync torrent files that were opened with write access.
* but it couldn't hurt... */
fcntl( fd, F_NOCACHE, 1 );
#endif
- tr_fsync( fd );
close( fd );
}
struct tr_cached_file * o;
if(( o = fileset_lookup( get_fileset( s ), tr_torrentId( tor ), i )))
+ {
+ /* flush writable files so that their mtimes will be
+ * up-to-date when this function returns to the caller... */
+ if( o->is_writable )
+ tr_fsync( o->fd );
+
cached_file_close( o );
+ }
}
int
/**
* Closes a file that's being held by our file repository.
*
- * If the file isn't checked out, it's closed immediately.
+ * If the file isn't checked out, it's fsync()ed and close()d immediately.
* If the file is currently checked out, it will be closed upon its return.
*
* @see tr_fdFileCheckout