Changeset 1207


Ignore:
Timestamp:
Dec 14, 2006, 4:25:35 AM (15 years ago)
Author:
titer
Message:

Properly release files when checking hashes

Location:
branches/io/libtransmission
Files:
2 edited

Legend:

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

    r1206 r1207  
    199199
    200200open:
    201     tr_dbg( "Opening %s in %s", name, folder );
     201    tr_dbg( "Opening %s in %s (%d)", name, folder, write );
    202202    asprintf( &path, "%s/%s", folder, name );
    203203    f->open[winner].file = open( path, write ? ( O_RDWR | O_CREAT ) :
     
    362362static void CloseFile( tr_fd_t * f, int i )
    363363{
    364     if( !( f->open[i].status & STATUS_UNUSED ) )
     364    tr_openFile_t * file = &f->open[i];
     365    if( !( file->status & STATUS_UNUSED ) )
    365366    {
    366367        tr_err( "CloseFile: status is %d, should be %d",
    367                 f->open[i].status, STATUS_UNUSED );
    368     }
    369     tr_dbg( "Closing %s in %s", f->open[i].name, f->open[i].folder );
    370     f->open[i].status = STATUS_CLOSING;
    371     tr_lockUnlock( &f->lock );
    372     close( f->open[i].file );
    373     tr_lockLock( &f->lock );
    374     f->open[i].status = STATUS_INVALID;
     368                file->status, STATUS_UNUSED );
     369    }
     370    tr_dbg( "Closing %s in %s (%d)", file->name, file->folder, file->write );
     371    file->status = STATUS_CLOSING;
     372    tr_lockUnlock( &f->lock );
     373    close( file->file );
     374    tr_lockLock( &f->lock );
     375    file->status = STATUS_INVALID;
    375376    tr_condSignal( &f->cond );
    376377}
  • branches/io/libtransmission/inout.c

    r1205 r1207  
    382382            if( lseek( file, offset, SEEK_SET ) < 0 )
    383383            {
     384                tr_fdFileRelease( tor->fdlimit, file );
    384385                goto fail;
    385386            }
     
    388389            if( readOrWrite( file, buf, cur ) != cur )
    389390            {
     391                tr_fdFileRelease( tor->fdlimit, file );
    390392                goto fail;
    391393            }
Note: See TracChangeset for help on using the changeset viewer.