Ignore:
Timestamp:
Apr 23, 2006, 5:03:12 PM (16 years ago)
Author:
titer
Message:

Use file descriptors instead of streams (preliminary cleanup for fixes
to come in fdlimit*)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r20 r238  
    3030{
    3131    char       path[MAX_PATH_LENGTH];
    32     FILE     * file;
     32    int        file;
    3333
    3434#define STATUS_INVALID 1
     
    100100 * tr_fdFileOpen
    101101 **********************************************************************/
    102 FILE * tr_fdFileOpen( tr_fd_t * f, char * path )
     102int tr_fdFileOpen( tr_fd_t * f, char * path )
    103103{
    104104    int i, winner;
     
    159159        {
    160160            /* Close the file: we mark it as closing then release the
    161                lock while doing so, because fclose may take same time
     161               lock while doing so, because close may take same time
    162162               and we don't want to block other threads */
    163163            tr_dbg( "Closing %s", f->open[winner].path );
    164164            f->open[winner].status = STATUS_CLOSING;
    165165            tr_lockUnlock( &f->lock );
    166             fclose( f->open[winner].file );
     166            close( f->open[winner].file );
    167167            tr_lockLock( &f->lock );
    168168            goto open;
     
    178178    tr_dbg( "Opening %s", path );
    179179    snprintf( f->open[winner].path, MAX_PATH_LENGTH, "%s", path );
    180     f->open[winner].file = fopen( path, "r+" );
     180    f->open[winner].file = open( path, O_RDWR, 0 );
    181181
    182182done:
     
    191191 * tr_fdFileRelease
    192192 **********************************************************************/
    193 void tr_fdFileRelease( tr_fd_t * f, FILE * file )
     193void tr_fdFileRelease( tr_fd_t * f, int file )
    194194{
    195195    int i;
     
    227227        {
    228228            tr_dbg( "Closing %s", path );
    229             fclose( f->open[i].file );
     229            close( f->open[i].file );
    230230            f->open[i].status = STATUS_INVALID;
    231231            break;
Note: See TracChangeset for help on using the changeset viewer.