Changeset 3674


Ignore:
Timestamp:
Nov 1, 2007, 1:47:32 PM (14 years ago)
Author:
charles
Message:

finish cleaning up the code that was churned during the "corruption" fix.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEWS

    r3669 r3674  
    22
    330.92 (2007/xx/yy)
     4- All Platforms:
     5   + Fix 0.90 data corruption bugs.
    46- OS X:
    57   + Leopard: Time Machine will ignore incomplete downloads
    68   + Leopard: Fix bug with typing values in Inspector->Options
    79   + Leopard: Fix bug with toggling Minimal View
     10- GTK
     11   + Better support for large files on some Linux systems
     12   + Fix localization error in torrent inspector's dates
     13   
    814
    9150.91 (2007/10/28)
    10 - libtransmission (all platforms):
     16- All Platforms:
    1117   + Fix 0.90 speed limits
    1218   + Fix 0.90 problems announcing to some trackers
  • trunk/libtransmission/fdlimit.c

    r3666 r3674  
    9090enum
    9191{
     92    TR_MAX_SOCKETS = 1024,
     93
    9294    TR_MAX_OPEN_FILES = 16, /* real files, not sockets */
    9395
     
    126128{
    127129    struct tr_openfile * file = &gFd->open[i];
    128     char * dir;
    129130    int flags;
    130131
     
    132133
    133134    /* create subfolders, if any */
    134     dir = dirname( tr_strdup( filename ) );
    135     if( write && tr_mkdirp( dir, 0700 ) ) {
    136         free( dir );
    137         return tr_ioErrorFromErrno( );
     135    if( write ) {
     136        char * dir = dirname( tr_strdup( filename ) );
     137        const int val = tr_mkdirp( dir, 0700 );
     138        tr_free( dir );
     139        if( val )
     140            return tr_ioErrorFromErrno( );
    138141    }
    139142
     
    145148    errno = 0;
    146149    file->fd = open( filename, flags, 0600 );
    147     free( dir );
    148150    if( file->fd < 0 ) {
    149151        if( errno ) {
     
    233235    for( ;; )
    234236    {
    235         uint64_t date = tr_date() + 1;
     237        uint64_t date = tr_date( ) + 1;
    236238        winner = -1;
    237239
     
    281283    dbgmsg( "checking out '%s' in slot %d", filename, winner );
    282284    o->isCheckedOut = 1;
    283     o->date = tr_date();
     285    o->date = tr_date( );
    284286    tr_lockUnlock( gFd->lock );
    285287    return o->fd;
     
    296298        if( o->fd == file ) {
    297299            dbgmsg( "releasing file '%s' in slot #%d", o->filename, i );
    298             if( o->isWritable )
    299                 fsync( o->fd ); /* fflush */
     300            fsync( o->fd );
    300301            o->isCheckedOut = 0;
    301302            break;
     
    329330
    330331int
    331 tr_fdSocketCreate( int type, int priority )
     332tr_fdSocketCreate( int type, int isReserved )
    332333{
    333334    int s = -1;
    334335    tr_lockLock( gFd->lock );
    335336
    336     if( priority && gFd->reserved >= TR_RESERVED_FDS )
    337         priority = FALSE;
    338 
    339     if( priority || ( gFd->normal < gFd->normalMax ) )
     337    if( isReserved && gFd->reserved >= TR_RESERVED_FDS )
     338        isReserved = FALSE;
     339
     340    if( isReserved || ( gFd->normal < gFd->normalMax ) )
    340341        if( ( s = socket( AF_INET, type, 0 ) ) < 0 )
    341342            tr_err( "Couldn't create socket (%s)", strerror( sockerrno ) );
     
    343344    if( s > -1 )
    344345    {
    345         setSocketPriority( s, priority );
    346 
    347         if( priority )
     346        setSocketPriority( s, isReserved );
     347
     348        if( isReserved )
    348349            ++gFd->reserved;
    349350        else
     
    376377    if( s > -1 )
    377378    {
    378         setSocketPriority( s, 0 );
     379        setSocketPriority( s, FALSE );
    379380        *addr = sock.sin_addr;
    380381        *port = sock.sin_port;
     
    424425tr_fdInit( void )
    425426{
    426     int i, j, s[4096];
     427    int i, j, s[TR_MAX_SOCKETS];
    427428
    428429    assert( gFd == NULL );
     
    433434
    434435    /* count the max number of sockets we can use */
    435     for( i=0; i<4096; ++i )
     436    for( i=0; i<TR_MAX_SOCKETS; ++i )
    436437        if( ( s[i] = socket( AF_INET, SOCK_STREAM, 0 ) ) < 0 )
    437438            break;
  • trunk/libtransmission/inout.c

    r3666 r3674  
    6363    int ret;
    6464
    65     assert ( 0<=fileIndex && fileIndex<info->fileCount );
    66     assert ( !file->length || (fileOffset < file->length));
    67     assert ( fileOffset + buflen <= file->length );
     65    assert( 0<=fileIndex && fileIndex<info->fileCount );
     66    assert( !file->length || (fileOffset < file->length));
     67    assert( fileOffset + buflen <= file->length );
    6868
    6969    tr_buildPath ( path, sizeof(path), tor->destination, file->name, NULL );
     
    9090static void
    9191findFileLocation( const tr_torrent * tor,
    92                   int                  pieceIndex,
    93                   int                  pieceOffset,
    94                   int                * fileIndex,
    95                   uint64_t           * fileOffset )
     92                  int                pieceIndex,
     93                  int                pieceOffset,
     94                  int              * fileIndex,
     95                  uint64_t         * fileOffset )
    9696{
    9797    const tr_info * info = &tor->info;
     
    100100    uint64_t piecePos = ((uint64_t)pieceIndex * info->pieceSize) + pieceOffset;
    101101
    102     assert ( 0<=pieceIndex && pieceIndex < info->pieceCount );
    103     assert ( 0<=tor->info.pieceSize );
    104     assert ( pieceOffset < tr_torPieceCountBytes( tor, pieceIndex ) );
    105     assert ( piecePos < info->totalSize );
    106 
    107     for ( i=0; info->files[i].length<=piecePos; ++i )
    108       piecePos -= info->files[i].length;
     102    assert( 0<=pieceIndex && pieceIndex < info->pieceCount );
     103    assert( 0<=tor->info.pieceSize );
     104    assert( pieceOffset < tr_torPieceCountBytes( tor, pieceIndex ) );
     105    assert( piecePos < info->totalSize );
     106
     107    for( i=0; info->files[i].length<=piecePos; ++i )
     108        piecePos -= info->files[i].length;
    109109
    110110    *fileIndex = i;
    111111    *fileOffset = piecePos;
    112112
    113     assert ( 0<=*fileIndex && *fileIndex<info->fileCount );
    114     assert ( *fileOffset < info->files[i].length );
     113    assert( 0<=*fileIndex && *fileIndex<info->fileCount );
     114    assert( *fileOffset < info->files[i].length );
    115115}
    116116
     
    127127    char path[MAX_PATH_LENGTH];
    128128
    129     assert ( 0<=fileIndex && fileIndex<tor->info.fileCount );
    130     assert ( minBytes <= file->length );
    131 
    132     tr_buildPath ( path, sizeof(path), tor->destination, file->name, NULL );
     129    assert( 0<=fileIndex && fileIndex<tor->info.fileCount );
     130    assert( minBytes <= file->length );
     131
     132    tr_buildPath( path, sizeof(path), tor->destination, file->name, NULL );
    133133
    134134    fd = tr_fdFileOpen( path, TRUE );
     
    192192
    193193int
    194 tr_ioRead( tr_torrent * tor, int pieceIndex, int begin, int len, uint8_t * buf )
     194tr_ioRead( tr_torrent  * tor,
     195           int           pieceIndex,
     196           int           begin,
     197           int           len,
     198           uint8_t     * buf )
    195199{
    196200    return readOrWritePiece( tor, TR_IO_READ, pieceIndex, begin, buf, len );
     
    198202
    199203int
    200 tr_ioWrite( tr_torrent * tor, int pieceIndex, int begin, int len, uint8_t * buf )
     204tr_ioWrite( tr_torrent  * tor,
     205            int           pieceIndex,
     206            int           begin,
     207            int           len,
     208            uint8_t     * buf )
    201209{
    202210    return readOrWritePiece( tor, TR_IO_WRITE, pieceIndex, begin, buf, len );
  • trunk/libtransmission/peer-msgs.c

    r3663 r3674  
    164164        char * myfile = tr_strdup( file );
    165165
    166         evbuffer_add_printf( buf, "[%s] %s [%s]: ",
     166        evbuffer_add_printf( buf, "[%s] %s - %s [%s]: ",
    167167                             tr_getLogTimeStr( timestr, sizeof(timestr) ),
     168                             msgs->torrent->info.name,
    168169                             tr_peerIoGetAddrStr( msgs->io ),
    169170                             msgs->info->client );
Note: See TracChangeset for help on using the changeset viewer.