(trunk libT) #3973 "JIT verification verifies fresh downloaded torrents" -- improvement to r11813.

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.
This commit is contained in:
Jordan Lee 2011-02-02 23:29:17 +00:00
parent 4bf6f0ac40
commit 22660ed751
2 changed files with 8 additions and 2 deletions

View File

@ -308,7 +308,6 @@ tr_close_file( int fd )
* but it couldn't hurt... */
fcntl( fd, F_NOCACHE, 1 );
#endif
tr_fsync( fd );
close( fd );
}
@ -526,7 +525,14 @@ tr_fdFileClose( tr_session * s, const tr_torrent * tor, tr_file_index_t i )
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

View File

@ -78,7 +78,7 @@ int tr_fdFileGetCached( tr_session * session,
/**
* 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