Ignore:
Timestamp:
Sep 1, 2007, 8:31:58 PM (15 years ago)
Author:
charles
Message:

harden the read/write event synchronization.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/encryption/libtransmission/peer-io.c

    r2965 r2971  
    113113    c->rateToPeer = tr_rcInit( );
    114114    c->rateToClient = tr_rcInit( );
     115fprintf( stderr, "io %p rates: peer %p client %p\n", c, c->rateToPeer, c->rateToClient );
    115116    c->bufev = bufferevent_new( c->socket,
    116117                                canReadWrapper,
     
    118119                                gotErrorWrapper,
    119120                                c );
     121    bufferevent_enable( c->bufev, EV_READ|EV_WRITE );
    120122    return c;
    121123}
     
    126128                      int                 socket )
    127129{
    128     tr_peerIo * c =
    129         tr_peerIoNew( handle, in_addr, NULL, 1, socket );
     130    tr_peerIo * c;
     131
     132    assert( handle != NULL );
     133    assert( in_addr != NULL );
     134    assert( socket >= 0 );
     135
     136    c = tr_peerIoNew( handle, in_addr, NULL, 1, socket );
    130137    c->port = -1;
    131138    return c;
     
    157164    {
    158165        bufferevent_free( c->bufev );
     166fprintf( stderr, "io %p destroying rate to client %p to peer %p\n", c, c->rateToClient, c->rateToPeer );
    159167        tr_rcClose( c->rateToClient );
    160168        tr_rcClose( c->rateToPeer );
     
    205213{
    206214    tr_setBufferEventMode( c->handle, c->bufev, enable, disable );
    207 }
    208 
    209 void
    210 tr_peerIoReadOrWait( tr_peerIo * c )
    211 {
    212     if( EVBUFFER_LENGTH( c->bufev->input ) )
    213         canReadWrapper( c->bufev, c );
    214     else
    215         tr_peerIoSetIOMode( c, EV_READ, EV_WRITE );
    216215}
    217216
Note: See TracChangeset for help on using the changeset viewer.