Changeset 1215


Ignore:
Timestamp:
Dec 14, 2006, 3:28:17 PM (15 years ago)
Author:
titer
Message:

Return the proper errors from tr_ioRead and tr_ioWrite

Location:
branches/io/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/io/libtransmission/inout.c

    r1207 r1215  
    106106/***********************************************************************
    107107 * tr_ioRead
    108  ***********************************************************************
    109  *
    110108 **********************************************************************/
    111109int tr_ioRead( tr_io_t * io, int index, int begin, int length,
     
    123121/***********************************************************************
    124122 * tr_ioWrite
    125  ***********************************************************************
    126  *
    127123 **********************************************************************/
    128124int tr_ioWrite( tr_io_t * io, int index, int begin, int length,
     
    137133    int            pieceSize;
    138134    int            startBlock, endBlock;
     135    int            ret;
    139136
    140137    if( io->pieceSlot[index] < 0 )
     
    148145        (uint64_t) inf->pieceSize + (uint64_t) begin;
    149146
    150     if( writeBytes( io, offset, length, buf ) )
    151     {
    152         return 1;
     147    if( ( ret = writeBytes( io, offset, length, buf ) ) )
     148    {
     149        return ret;
    153150    }
    154151
     
    327324    int    file;
    328325    iofunc readOrWrite = isWrite ? (iofunc) write : (iofunc) read;
     326    int    ret = 0;
    329327
    330328    /* Release the torrent lock so the UI can still update itself if
     
    336334    {
    337335        tr_err( "readOrWriteBytes: trying to write more than a piece" );
    338         goto fail;
     336        ret = TR_ERROR_ASSERT;
     337        goto cleanup;
    339338    }
    340339
     
    354353        tr_err( "readOrWriteBytes: offset out of range (%"PRIu64", %d, %d)",
    355354                offset, size, isWrite );
    356         goto fail;
     355        ret = TR_ERROR_ASSERT;
     356        goto cleanup;
    357357    }
    358358
     
    376376            if( file < 0 )
    377377            {
    378                 goto fail;
     378                ret = file;
     379                goto cleanup;
    379380            }
    380381
     
    383384            {
    384385                tr_fdFileRelease( tor->fdlimit, file );
    385                 goto fail;
     386                ret = TR_ERROR_IO_OTHER;
     387                goto cleanup;
    386388            }
    387389
     
    390392            {
    391393                tr_fdFileRelease( tor->fdlimit, file );
    392                 goto fail;
     394                ret = TR_ERROR_IO_OTHER;
     395                goto cleanup;
    393396            }
    394397
     
    404407    }
    405408
     409cleanup:
    406410    tr_lockLock( &tor->lock );
    407     return 0;
    408 
    409 fail:
    410     tr_lockLock( &tor->lock );
    411     return 1;
     411    return ret;
    412412}
    413413
  • branches/io/libtransmission/inout.h

    r346 r1215  
    3131
    3232tr_io_t * tr_ioInit        ( tr_torrent_t * );
     33
     34/***********************************************************************
     35 * tr_ioRead, tr_ioWrite
     36 ***********************************************************************
     37 * Reads or writes the block specified by the piece index, the offset in
     38 * that piece and the size of the block. Returns 0 if successful,
     39 * TR_ERROR_ASSERT if the parameters are incorrect, one of the
     40 * TR_ERROR_IO_* otherwise.
     41 **********************************************************************/
    3342int       tr_ioRead        ( tr_io_t *, int, int, int, uint8_t * );
    3443int       tr_ioWrite       ( tr_io_t *, int, int, int, uint8_t * );
     44
    3545void      tr_ioClose       ( tr_io_t * );
    3646void      tr_ioSaveResume  ( tr_io_t * );
  • branches/io/libtransmission/transmission.h

    r1198 r1215  
    5656 * Error codes
    5757 **********************************************************************/
     58/* General errors */
     59#define TR_ERROR_ASSERT         -1
     60/* I/O errors */
    5861#define TR_ERROR_IO_PARENT      -10
    5962#define TR_ERROR_IO_PERMISSIONS -11
Note: See TracChangeset for help on using the changeset viewer.