Changeset 9339


Ignore:
Timestamp:
Oct 20, 2009, 8:19:41 PM (13 years ago)
Author:
charles
Message:

(trunk libT) #1483: fix bug introduced in r9328

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r9328 r9339  
    388388                    tr_bool          doWrite )
    389389{
    390     int i;
    391     struct tr_openfile * o;
     390    struct tr_openfile * match = NULL;
    392391
    393392    assert( torrentId > 0 );
     
    395394
    396395    /* is it already open? */
    397     for( i=0; i<gFd->openFileLimit; ++i )
    398     {
    399         o = &gFd->openFiles[i];
    400 
    401         if( !fileIsOpen( o ) )
    402             continue;
    403         if( torrentId != o->torrentId )
    404             continue;
    405         if( fileNum != o->fileNum )
    406             continue;
    407 
    408         break;
    409     }
    410 
    411     if( ( o != NULL ) && ( !doWrite || o->isWritable ) )
    412     {
    413         o->date = tr_date( );
    414         return o->fd;
     396    {
     397        int i;
     398        struct tr_openfile * o;
     399        for( i=0; i<gFd->openFileLimit; ++i )
     400        {
     401            o = &gFd->openFiles[i];
     402
     403            if( torrentId != o->torrentId )
     404                continue;
     405            if( fileNum != o->fileNum )
     406                continue;
     407            if( !fileIsOpen( o ) )
     408                continue;
     409
     410            match = o;
     411            break;
     412        }
     413    }
     414
     415    if( ( match != NULL ) && ( !doWrite || match->isWritable ) )
     416    {
     417        match->date = tr_date( );
     418        return match->fd;
    415419    }
    416420
     
    445449        o = &gFd->openFiles[i];
    446450
    447         if( !fileIsOpen( o ) )
    448             continue;
    449451        if( torrentId != o->torrentId )
    450452            continue;
    451453        if( fileNum != o->fileNum )
     454            continue;
     455        if( !fileIsOpen( o ) )
    452456            continue;
    453457
     
    529533    for( o=gFd->openFiles, end=o+gFd->openFileLimit; o!=end; ++o )
    530534    {
    531         if( !fileIsOpen( o ) )
    532             continue;
    533535        if( torrentId != o->torrentId )
    534536            continue;
    535537        if( fileNum != o->fileNum )
    536538            continue;
     539        if( !fileIsOpen( o ) )
     540            continue;
    537541
    538542        dbgmsg( "tr_fdFileClose closing \"%s\"", o->filename );
     
    548552
    549553    for( o=gFd->openFiles, end=o+gFd->openFileLimit; o!=end; ++o )
    550         if( fileIsOpen( o ) && o->torrentId == torrentId )
     554        if( fileIsOpen( o ) && ( o->torrentId == torrentId ) )
    551555            TrCloseFile( o );
    552556}
Note: See TracChangeset for help on using the changeset viewer.