Ignore:
Timestamp:
Oct 14, 2010, 4:21:14 AM (12 years ago)
Author:
charles
Message:

(trunk libT) #3631 "crash in tr_ioFindFileLocation" -- add tracer messages to try & smoke out the error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/inout.c

    r11273 r11310  
    168168
    169169static int
    170 compareOffsetToFile( const void * a,
    171                      const void * b )
     170compareOffsetToFile( const void * a, const void * b )
    172171{
    173172    const uint64_t  offset = *(const uint64_t*)a;
     
    189188    const tr_file * file;
    190189
     190    assert( tr_isTorrent( tor ) );
     191    assert( offset < tor->info.totalSize );
     192
    191193    file = bsearch( &offset,
    192194                    tor->info.files, tor->info.fileCount, sizeof( tr_file ),
    193195                    compareOffsetToFile );
     196
     197if( file == NULL ) {
     198unsigned int i;
     199fprintf( stderr, "%s", "transmission error\n" );
     200fprintf( stderr, "pieceIndex %d\n", (int)pieceIndex );
     201fprintf( stderr, "pieceOffset %d\n", (int)pieceOffset );
     202fprintf( stderr, "couldn't find file matching offset %"PRIu64"\n", offset );
     203fprintf( stderr, "total torrent size %"PRIu64"\n", tor->info.totalSize );
     204fprintf( stderr, "%u files\n", (unsigned int)tor->info.fileCount );
     205for( 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 );
     206}
     207
     208    assert( file != NULL );
    194209
    195210    *fileIndex = file - tor->info.files;
Note: See TracChangeset for help on using the changeset viewer.