mirror of
https://github.com/transmission/transmission
synced 2025-01-31 03:12:44 +00:00
(trunk libT) #3631 "crash in tr_ioFindFileLocation" -- add tracer messages to try & smoke out the error
This commit is contained in:
parent
35ac787457
commit
dbed40ff5a
1 changed files with 17 additions and 2 deletions
|
@ -167,8 +167,7 @@ readOrWriteBytes( tr_session * session,
|
|||
}
|
||||
|
||||
static int
|
||||
compareOffsetToFile( const void * a,
|
||||
const void * b )
|
||||
compareOffsetToFile( const void * a, const void * b )
|
||||
{
|
||||
const uint64_t offset = *(const uint64_t*)a;
|
||||
const tr_file * file = b;
|
||||
|
@ -188,10 +187,26 @@ tr_ioFindFileLocation( const tr_torrent * tor,
|
|||
const uint64_t offset = tr_pieceOffset( tor, pieceIndex, pieceOffset, 0 );
|
||||
const tr_file * file;
|
||||
|
||||
assert( tr_isTorrent( tor ) );
|
||||
assert( offset < tor->info.totalSize );
|
||||
|
||||
file = bsearch( &offset,
|
||||
tor->info.files, tor->info.fileCount, sizeof( tr_file ),
|
||||
compareOffsetToFile );
|
||||
|
||||
if( file == NULL ) {
|
||||
unsigned int i;
|
||||
fprintf( stderr, "%s", "transmission error\n" );
|
||||
fprintf( stderr, "pieceIndex %d\n", (int)pieceIndex );
|
||||
fprintf( stderr, "pieceOffset %d\n", (int)pieceOffset );
|
||||
fprintf( stderr, "couldn't find file matching offset %"PRIu64"\n", offset );
|
||||
fprintf( stderr, "total torrent size %"PRIu64"\n", tor->info.totalSize );
|
||||
fprintf( stderr, "%u files\n", (unsigned int)tor->info.fileCount );
|
||||
for( i=0; i<tor->info.fileCount; ++i ) fprintf( stderr, "file #%u offset %"PRIu64" length %"PRIu64"\n", i, tor->info.files[i].offset, tor->info.files[i].length );
|
||||
}
|
||||
|
||||
assert( file != NULL );
|
||||
|
||||
*fileIndex = file - tor->info.files;
|
||||
*fileOffset = offset - file->offset;
|
||||
|
||||
|
|
Loading…
Reference in a new issue