add better logging to track down tr_ioRead() error messages reported by Rabbitbunny

This commit is contained in:
Charles Kerr 2009-09-08 06:25:40 +00:00
parent bd41421591
commit c7e2a29f57
2 changed files with 18 additions and 7 deletions

View File

@ -352,8 +352,13 @@ TrOpenFile( int i,
#ifdef HAVE_POSIX_FADVISE
/* this doubles the OS level readahead buffer, which in practice
* turns out to be a good thing, because many (most?) clients request
* chunks of blocks in order */
posix_fadvise( file->fd, 0, 0, POSIX_FADV_SEQUENTIAL );
* chunks of blocks in order.
* It's okay for this to fail silently, so don't let it affect errno */
{
const int err = errno;
posix_fadvise( file->fd, 0, 0, POSIX_FADV_SEQUENTIAL );
errno = err;
}
#endif
tr_free( filename );

View File

@ -100,13 +100,19 @@ readOrWriteBytes( const tr_torrent * tor,
preallocationMode = tor->session->preallocationMode;
if( ( ioMode == TR_IO_READ ) && !fileExists ) /* does file exist? */
err = ENOENT;
else if( ( fd = tr_fdFileCheckout( tor->uniqueId, tor->downloadDir, file->name, ioMode == TR_IO_WRITE, preallocationMode, file->length ) ) < 0 ) {
err = errno;
else if( ( fd = tr_fdFileCheckout ( tor->uniqueId, tor->downloadDir, file->name, ioMode == TR_IO_WRITE, preallocationMode, file->length ) ) < 0 )
tr_torerr( tor, "tr_fdFileCheckout failed for \"%s\": %s", file->name, tr_strerror( err ) );
}
else if( tr_lseek( fd, (int64_t)fileOffset, SEEK_SET ) == -1 ) {
err = errno;
else if( tr_lseek( fd, (int64_t)fileOffset, SEEK_SET ) == -1 )
err = errno;
else if( func( fd, buf, buflen ) != buflen )
tr_torerr( tor, "tr_lseek failed for \"%s\": %s", file->name, tr_strerror( err ) );
}
else if( func( fd, buf, buflen ) != buflen ) {
err = errno;
tr_torerr( tor, "read/write failed for \"%s\": %s", file->name, tr_strerror( err ) );
}
else
err = 0;
@ -175,7 +181,7 @@ readOrWritePiece( tr_torrent * tor,
while( buflen && !err )
{
const tr_file * file = &info->files[fileIndex];
const uint64_t bytesThisPass = MIN( buflen, file->length - fileOffset );
const uint64_t bytesThisPass = MIN( buflen, file->length - fileOffset );
err = readOrWriteBytes( tor, ioMode, fileIndex, fileOffset, buf, bytesThisPass );
buf += bytesThisPass;