Changeset 11748


Ignore:
Timestamp:
Jan 22, 2011, 1:33:05 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) #3927 "Use of libevent2 evbuffer_write on files..."

evbuffer_write() is intended for sockets. It works for files on Unix, but not on Windows, so we can't portably use it on files. Instead, use evbuffer_pullup() + write().

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bencode.c

    r11709 r11748  
    16851685        /* save the benc to a temporary file */
    16861686        {
    1687             struct evbuffer * buffer = evbuffer_new( );
    1688             tr_bencToBuf( top, mode, buffer );
    1689             nleft = evbuffer_get_length( buffer );
     1687            char * buf = tr_bencToStr( top, mode, &nleft );
     1688            const char * walk = buf;
    16901689            while( nleft > 0 ) {
    1691                 const int n = evbuffer_write( buffer, fd );
    1692                 if( n >= 0 )
     1690                const int n = write( fd, walk, nleft );
     1691                if( n >= 0 ) {
    16931692                    nleft -= n;
     1693                    walk += n;
     1694                }
    16941695                else if( errno != EAGAIN ) {
    16951696                    err = errno;
     
    16971698                }
    16981699            }
    1699             evbuffer_free( buffer );
     1700            tr_free( buf );
    17001701        }
    17011702
  • trunk/libtransmission/peer-msgs.c

    r11709 r11748  
    279279        va_end( args );
    280280        evbuffer_add_printf( buf, " (%s:%d)\n", base, line );
    281         evbuffer_write( buf, fileno( fp ) );
     281        fputs( (const char*)evbuffer_pullup( buf, -1 ), fp );
    282282
    283283        tr_free( base );
  • trunk/libtransmission/utils.c

    r11714 r11748  
    245245        OutputDebugString( evbuffer_pullup( buf, -1 ) );
    246246        if( fp )
    247             evbuffer_write( buf, fileno( fp ) );
     247            fputs( (const char*)evbuffer_pullup( buf, -1 ), fp );
    248248
    249249        tr_free( base );
Note: See TracChangeset for help on using the changeset viewer.