Changeset 11588


Ignore:
Timestamp:
Dec 24, 2010, 8:58:41 AM (11 years ago)
Author:
charles
Message:

(trunk libT) #3836 "libevent2 support" -- finish moving to the libevent2 API mode. don't include the backwards-compatable API headers.

Location:
trunk/libtransmission
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/JSON_parser.c

    r10518 r11588  
    7070
    7171#include <stdarg.h> /* some 1.4.x versions of evutil.h need this */
    72 #include <evutil.h> /* evutil_strtoll() */
     72#include <event2/util.h> /* evutil_strtoll() */
    7373
    7474#include "JSON_parser.h"
  • trunk/libtransmission/announcer.c

    r11548 r11588  
    265265    a->slotsAvailable = MAX_CONCURRENT_TASKS;
    266266    a->lpdHouseKeepingAt = relaxUntil;
    267     a->upkeepTimer = evtimer_new( NULL, onUpkeepTimer, a );
     267    a->upkeepTimer = evtimer_new( session->event_base, onUpkeepTimer, a );
    268268    tr_timerAdd( a->upkeepTimer, UPKEEP_INTERVAL_SECS, 0 );
    269269
  • trunk/libtransmission/handshake.c

    r11548 r11588  
    11661166
    11671167tr_handshake*
    1168 tr_handshakeNew( tr_peerIo *        io,
    1169                  tr_encryption_mode encryptionMode,
    1170                  handshakeDoneCB    doneCB,
    1171                  void *            doneUserData )
     1168tr_handshakeNew( tr_peerIo           * io,
     1169                 tr_encryption_mode    encryptionMode,
     1170                 handshakeDoneCB       doneCB,
     1171                 void                * doneUserData )
    11721172{
    11731173    tr_handshake * handshake;
     1174    tr_session * session = tr_peerIoGetSession( io );
    11741175
    11751176    handshake = tr_new0( tr_handshake, 1 );
     
    11791180    handshake->doneCB = doneCB;
    11801181    handshake->doneUserData = doneUserData;
    1181     handshake->session = tr_peerIoGetSession( io );
    1182     handshake->timeout_timer = evtimer_new( NULL, handshakeTimeout, handshake );
     1182    handshake->session = session;
     1183    handshake->timeout_timer = evtimer_new( session->event_base, handshakeTimeout, handshake );
    11831184    tr_timerAdd( handshake->timeout_timer, HANDSHAKE_TIMEOUT_SEC, 0 );
    11841185
  • trunk/libtransmission/net.c

    r11494 r11588  
    4545#include <unistd.h>
    4646
    47 #include <stdarg.h> /* some 1.4.x versions of evutil.h need this */
    48 #include <evutil.h>
     47#include <event2/util.h>
    4948
    5049#include "transmission.h"
  • trunk/libtransmission/peer-io.c

    r11554 r11588  
    395395    io->inbuf = evbuffer_new( );
    396396    io->outbuf = evbuffer_new( );
    397     io->event_read = event_new( NULL, io->socket, EV_READ, event_read_cb, io );
    398     io->event_write = event_new( NULL, io->socket, EV_WRITE, event_write_cb, io );
     397    io->event_read = event_new( session->event_base, io->socket, EV_READ, event_read_cb, io );
     398    io->event_write = event_new( session->event_base, io->socket, EV_WRITE, event_write_cb, io );
    399399    tr_bandwidthConstruct( &io->bandwidth, session, parent );
    400400    tr_bandwidthSetPeer( &io->bandwidth, io );
     
    645645    event_del( io->event_write );
    646646    io->socket = tr_netOpenPeerSocket( session, &io->addr, io->port, io->isSeed );
    647     io->event_read = event_new( NULL, io->socket, EV_READ, event_read_cb, io );
    648     io->event_write = event_new( NULL, io->socket, EV_WRITE, event_write_cb, io );
     647    io->event_read = event_new( session->event_base, io->socket, EV_READ, event_read_cb, io );
     648    io->event_write = event_new( session->event_base, io->socket, EV_WRITE, event_write_cb, io );
    649649
    650650    if( io->socket >= 0 )
  • trunk/libtransmission/peer-mgr.c

    r11579 r11588  
    1717#include <stdlib.h> /* qsort */
    1818
    19 #include <event.h>
     19#include <event2/event.h>
    2020
    2121#include "transmission.h"
     
    504504    if( *t != NULL )
    505505    {
    506         evtimer_del( *t );
    507         tr_free( *t );
     506        event_free( *t );
    508507        *t = NULL;
    509508    }
     
    20432042
    20442043static struct event *
    2045 createTimer( int msec, void (*callback)(int, short, void *), void * cbdata )
    2046 {
    2047     struct event * timer = tr_new0( struct event, 1 );
    2048     evtimer_set( timer, callback, cbdata );
     2044createTimer( tr_session * session, int msec, void (*callback)(int, short, void *), void * cbdata )
     2045{
     2046    struct event * timer = evtimer_new( session->event_base, callback, cbdata );
    20492047    tr_timerAddMsec( timer, msec );
    20502048    return timer;
     
    20552053{
    20562054    if( m->atomTimer == NULL )
    2057         m->atomTimer = createTimer( ATOM_PERIOD_MSEC, atomPulse, m );
     2055        m->atomTimer = createTimer( m->session, ATOM_PERIOD_MSEC, atomPulse, m );
    20582056
    20592057    if( m->bandwidthTimer == NULL )
    2060         m->bandwidthTimer = createTimer( BANDWIDTH_PERIOD_MSEC, bandwidthPulse, m );
     2058        m->bandwidthTimer = createTimer( m->session, BANDWIDTH_PERIOD_MSEC, bandwidthPulse, m );
    20612059
    20622060    if( m->rechokeTimer == NULL )
    2063         m->rechokeTimer = createTimer( RECHOKE_PERIOD_MSEC, rechokePulse, m );
    2064 
    2065    if( m->refillUpkeepTimer == NULL )
    2066         m->refillUpkeepTimer = createTimer( REFILL_UPKEEP_PERIOD_MSEC, refillUpkeep, m );
     2061        m->rechokeTimer = createTimer( m->session, RECHOKE_PERIOD_MSEC, rechokePulse, m );
     2062
     2063    if( m->refillUpkeepTimer == NULL )
     2064        m->refillUpkeepTimer = createTimer( m->session, REFILL_UPKEEP_PERIOD_MSEC, refillUpkeep, m );
    20672065}
    20682066
  • trunk/libtransmission/peer-msgs.c

    r11548 r11588  
    23352335    m->outMessagesBatchPeriod = LOW_PRIORITY_INTERVAL_SECS;
    23362336    m->incoming.block = evbuffer_new( );
    2337     m->pexTimer = evtimer_new( NULL, pexPulse, m );
     2337    m->pexTimer = evtimer_new( torrent->session->event_base, pexPulse, m );
    23382338    peer->msgs = m;
    23392339    tr_timerAdd( m->pexTimer, PEX_INTERVAL_SECS, 0 );
  • trunk/libtransmission/port-forwarding.c

    r10945 r11588  
    1717#include <sys/types.h>
    1818
    19 #include <event.h>
     19#include <event2/event.h>
    2020
    2121#include "transmission.h"
     
    173173    if( s->timer != NULL )
    174174    {
    175         evtimer_del( s->timer );
    176         tr_free( s->timer );
     175        event_free( s->timer );
    177176        s->timer = NULL;
    178177    }
     
    210209start_timer( tr_shared * s )
    211210{
    212     s->timer = tr_new0( struct event, 1 );
    213     evtimer_set( s->timer, onTimer, s );
     211    s->timer = evtimer_new( s->session->event_base, onTimer, s );
    214212    set_evtimer_from_status( s );
    215213}
  • trunk/libtransmission/rpc-server.c

    r11548 r11588  
    2525#endif
    2626
    27 #include <event.h>
    28 #include <evhttp.h>
     27#include <event2/buffer.h>
     28#include <event2/event.h>
     29#include <event2/http.h>
     30#include <event2/http_struct.h> /* TODO: eventually remove this */
    2931
    3032#include "transmission.h"
     
    3840#include "rpcimpl.h"
    3941#include "rpc-server.h"
     42#include "session.h"
    4043#include "trevent.h"
    4144#include "utils.h"
     
    161164{
    162165    const char * content_type = evhttp_find_header( headers, "Content-Type" );
    163     const char * in = (const char*) EVBUFFER_DATA( body );
     166    const char * in = (const char*) evbuffer_pullup( body, -1 );
    164167    size_t inlen = evbuffer_get_length( body );
    165168
     
    278281                tr_bencToBuf( &top, TR_FMT_JSON, json );
    279282                tr_rpc_request_exec_json( server->session,
    280                                           EVBUFFER_DATA( json ),
     283                                          evbuffer_pullup( json, -1 ),
    281284                                          evbuffer_get_length( json ),
    282285                                          NULL, NULL );
     
    551554    {
    552555        tr_rpc_request_exec_json( server->session,
    553                                   EVBUFFER_DATA( req->input_buffer ),
     556                                  evbuffer_pullup( req->input_buffer, -1 ),
    554557                                  evbuffer_get_length( req->input_buffer ),
    555558                                  rpc_response_func, data );
     
    687690        addr.type = TR_AF_INET;
    688691        addr.addr.addr4 = server->bindAddress;
    689         server->httpd = evhttp_new( tr_eventGetBase( server->session ) );
    690         evhttp_bind_socket( server->httpd, tr_ntop_non_ts( &addr ),
    691                             server->port );
     692        server->httpd = evhttp_new( server->session->event_base );
     693        evhttp_bind_socket( server->httpd, tr_ntop_non_ts( &addr ), server->port );
    692694        evhttp_set_gencb( server->httpd, handle_request, server );
    693695
  • trunk/libtransmission/rpcimpl.c

    r11583 r11588  
    2222#endif
    2323
    24 #include <event.h> /* evbuffer */
     24#include <event2/buffer.h>
    2525
    2626#include "transmission.h"
  • trunk/libtransmission/session.c

    r11583 r11588  
    2222#include <dirent.h> /* opendir */
    2323
    24 #include <event.h>
     24#include <event2/event.h>
    2525
    2626//#define TR_SHOW_DEPRECATED
     
    144144    int socket;
    145145    tr_address addr;
    146     struct event ev;
     146    struct event * ev;
    147147};
    148148
     
    153153    if( ( b != NULL ) && ( b->socket >=0 ) )
    154154    {
    155         event_del( &b->ev );
     155        event_free( b->ev );
     156        b->ev = NULL;
    156157        tr_netCloseSocket( b->socket );
    157158    }
     
    202203    b->socket = tr_netBindTCP( &b->addr, session->private_peer_port, FALSE );
    203204    if( b->socket >= 0 ) {
    204         event_set( &b->ev, b->socket, EV_READ | EV_PERSIST, accept_incoming_peer, session );
    205         event_add( &b->ev, NULL );
     205        b->ev = event_new( session->event_base, b->socket, EV_READ | EV_PERSIST, accept_incoming_peer, session );
     206        event_add( b->ev, NULL );
    206207    }
    207208
     
    211212        b->socket = tr_netBindTCP( &b->addr, session->private_peer_port, FALSE );
    212213        if( b->socket >= 0 ) {
    213             event_set( &b->ev, b->socket, EV_READ | EV_PERSIST, accept_incoming_peer, session );
    214             event_add( &b->ev, NULL );
     214            b->ev = event_new( session->event_base, b->socket, EV_READ | EV_PERSIST, accept_incoming_peer, session );
     215            event_add( b->ev, NULL );
    215216        }
    216217    }
     
    604605    tr_bencMergeDicts( &settings, clientSettings );
    605606
    606     session->nowTimer = tr_new0( struct event, 1 );
    607     evtimer_set( session->nowTimer, onNowTimer, session );
     607    assert( session->event_base != NULL );
     608    session->nowTimer = evtimer_new( session->event_base, onNowTimer, session );
    608609    onNowTimer( 0, 0, session );
    609610
     
    634635    assert( tr_isSession( session ) );
    635636
    636     session->saveTimer = tr_new0( struct event, 1 );
    637     evtimer_set( session->saveTimer, onSaveTimer, session );
     637    session->saveTimer = evtimer_new( session->event_base, onSaveTimer, session );
    638638    tr_timerAdd( session->saveTimer, SAVE_INTERVAL_SECS, 0 );
    639639
     
    16671667        tr_dhtUninit( session );
    16681668
    1669     evtimer_del( session->saveTimer );
    1670     tr_free( session->saveTimer );
     1669    event_free( session->saveTimer );
    16711670    session->saveTimer = NULL;
    16721671
    1673     evtimer_del( session->nowTimer );
    1674     tr_free( session->nowTimer );
     1672    event_free( session->nowTimer );
    16751673    session->nowTimer = NULL;
    16761674
     
    17561754            dbgmsg( "calling event_loopbreak()" );
    17571755            forced = TRUE;
    1758             event_loopbreak( );
     1756            event_base_loopbreak( session->event_base );
    17591757        }
    17601758        if( deadlineReached( deadline+3 ) )
  • trunk/libtransmission/session.h

    r11522 r11588  
    3838const uint8_t* tr_getPeerId( void );
    3939
     40struct event_base;
    4041struct tr_address;
    4142struct tr_announcer;
     
    118119    tr_preallocation_mode        preallocationMode;
    119120
    120     struct tr_event_handle *     events;
     121    struct event_base          * event_base;
     122    struct tr_event_handle     * events;
    121123
    122124    uint16_t                     peerLimitPerTorrent;
  • trunk/libtransmission/torrent.c

    r11583 r11588  
    2424#include <stdlib.h> /* qsort */
    2525
    26 #include <stdarg.h> /* some 1.4.x versions of evutil.h need this */
    27 #include <evutil.h> /* evutil_vsnprintf() */
     26#include <event2/util.h> /* evutil_vsnprintf() */
    2827
    2928#include "transmission.h"
  • trunk/libtransmission/tr-dht.c

    r11548 r11588  
    401401    tr_threadNew( dht_bootstrap, cl );
    402402
    403     dht_event = event_new( NULL, dht_socket, EV_READ, event_callback, NULL );
     403    dht_event = event_new( session->event_base, dht_socket, EV_READ, event_callback, NULL );
    404404    tr_timerAdd( dht_event, 0, tr_cryptoWeakRandInt( 1000000 ) );
    405405
    406406    if( dht6_socket >= 0 )
    407407    {
    408         dht6_event = event_new( NULL, dht6_socket, EV_READ, event_callback, NULL );
     408        dht6_event = event_new( session->event_base, dht6_socket, EV_READ, event_callback, NULL );
    409409        tr_timerAdd( dht6_event, 0, tr_cryptoWeakRandInt( 1000000 ) );
    410410    }
  • trunk/libtransmission/tr-lpd.c

    r11548 r11588  
    339339     * any announcement received during the initial interval will be discarded. */
    340340
    341     lpd_event = event_new( NULL, lpd_socket, EV_READ | EV_PERSIST, event_callback, NULL );
     341    lpd_event = event_new( ss->event_base, lpd_socket, EV_READ | EV_PERSIST, event_callback, NULL );
    342342    event_add( lpd_event, NULL );
    343343
  • trunk/libtransmission/trevent.c

    r11548 r11588  
    1919#include <signal.h>
    2020
    21 #include <event.h>
     21#include <event2/event.h>
    2222
    2323#include "transmission.h"
     
    144144    tr_thread *  thread;
    145145    struct event_base * base;
    146     struct event pipeEvent;
     146    struct event * pipeEvent;
    147147}
    148148tr_event_handle;
     
    199199        {
    200200            dbgmsg( "pipe eof reached... removing event listener" );
    201             event_del( &eh->pipeEvent );
     201            event_free( eh->pipeEvent );
    202202            break;
    203203        }
     
    223223libeventThreadFunc( void * veh )
    224224{
     225    struct event_base * base;
    225226    tr_event_handle * eh = veh;
    226227
     
    230231#endif
    231232
    232     eh->base = event_init( );
     233    base = event_base_new( );
     234    eh->base = base;
     235    eh->session->event_base = base;
    233236    eh->session->events = eh;
    234237
    235238    /* listen to the pipe's read fd */
    236     event_set( &eh->pipeEvent, eh->fds[0], EV_READ | EV_PERSIST, readFromPipe, veh );
    237     event_add( &eh->pipeEvent, NULL );
     239    eh->pipeEvent = event_new( base, eh->fds[0], EV_READ | EV_PERSIST, readFromPipe, veh );
     240    event_add( eh->pipeEvent, NULL );
    238241    event_set_log_callback( logFunc );
    239242
    240243    /* loop until all the events are done */
    241244    while( !eh->die )
    242         event_dispatch( );
     245        event_base_dispatch( base );
    243246
    244247    /* shut down the thread */
    245248    tr_lockFree( eh->lock );
    246     event_base_free( eh->base );
     249    event_base_free( base );
    247250    eh->session->events = NULL;
    248251    tr_free( eh );
     
    321324    }
    322325}
    323 
    324 struct event_base *
    325 tr_eventGetBase( tr_session * session )
    326 {
    327     assert( tr_isSession( session ) );
    328 
    329     return session->events->base;
    330 }
  • trunk/libtransmission/trevent.h

    r9868 r11588  
    3232void      tr_runInEventThread( tr_session *, void func( void* ), void * user_data );
    3333
    34 struct event_base * tr_eventGetBase( tr_session * );
    35 
    3634#endif
Note: See TracChangeset for help on using the changeset viewer.