mirror of
https://github.com/transmission/transmission
synced 2025-02-23 06:30:38 +00:00
(trunk libT) minor tweak to verify: use tr_pread() instead of lseek+read
This commit is contained in:
parent
d3ae2cf696
commit
adc7d6f8a4
1 changed files with 6 additions and 9 deletions
|
@ -72,6 +72,7 @@ verifyTorrent( tr_torrent * tor, tr_bool * stopFlag )
|
||||||
int64_t leftInPiece;
|
int64_t leftInPiece;
|
||||||
int64_t leftInFile;
|
int64_t leftInFile;
|
||||||
int64_t bytesThisPass;
|
int64_t bytesThisPass;
|
||||||
|
ssize_t numRead;
|
||||||
const tr_file * file = &tor->info.files[fileIndex];
|
const tr_file * file = &tor->info.files[fileIndex];
|
||||||
|
|
||||||
/* if we're starting a new piece... */
|
/* if we're starting a new piece... */
|
||||||
|
@ -108,17 +109,13 @@ verifyTorrent( tr_torrent * tor, tr_bool * stopFlag )
|
||||||
/* fprintf( stderr, "reading this pass: %d\n", (int)bytesThisPass ); */
|
/* fprintf( stderr, "reading this pass: %d\n", (int)bytesThisPass ); */
|
||||||
|
|
||||||
/* read a bit */
|
/* read a bit */
|
||||||
if( (fd>=0) && tr_lseek( fd, filePos, SEEK_SET ) != -1 ) {
|
numRead = tr_pread( fd, buffer, bytesThisPass, filePos );
|
||||||
const int64_t numRead = read( fd, buffer, bytesThisPass );
|
if( numRead == bytesThisPass )
|
||||||
if( numRead > 0 )
|
SHA1_Update( &sha, buffer, numRead );
|
||||||
pieceBytesRead += numRead;
|
if( numRead > 0 ) {
|
||||||
if( numRead == bytesThisPass )
|
pieceBytesRead += numRead;
|
||||||
SHA1_Update( &sha, buffer, numRead );
|
|
||||||
#if defined HAVE_POSIX_FADVISE && defined POSIX_FADV_DONTNEED
|
#if defined HAVE_POSIX_FADVISE && defined POSIX_FADV_DONTNEED
|
||||||
posix_fadvise( fd, filePos, bytesThisPass, POSIX_FADV_DONTNEED );
|
posix_fadvise( fd, filePos, bytesThisPass, POSIX_FADV_DONTNEED );
|
||||||
#endif
|
|
||||||
#ifdef SYS_DARWIN
|
|
||||||
fcntl( fd, F_NOCACHE, 1 );
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue