Changeset 11659


Ignore:
Timestamp:
Jan 9, 2011, 9:48:51 PM (11 years ago)
Author:
jch
Message:

Update tr-{dht,udp} to libevent2.

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/tr-dht.c

    r11657 r11659  
    6060#include "utils.h"
    6161
    62 static struct event dht_timer;
     62static struct event *dht_timer = NULL;
    6363static unsigned char myid[20];
    6464static tr_session *session = NULL;
     
    316316    tr_threadNew( dht_bootstrap, cl );
    317317
    318     evtimer_set( &dht_timer, timer_callback, session );
    319     tr_timerAdd( &dht_timer, 0, tr_cryptoWeakRandInt( 1000000 ) );
     318    dht_timer = evtimer_new( NULL, timer_callback, session );
     319    tr_timerAdd( dht_timer, 0, tr_cryptoWeakRandInt( 1000000 ) );
    320320
    321321    tr_ndbg( "DHT", "DHT initialized" );
     
    337337    tr_ndbg( "DHT", "Uninitializing DHT" );
    338338
    339     event_del( &dht_timer );
     339    event_free( dht_timer );
     340    dht_timer = NULL;
    340341
    341342    /* Since we only save known good nodes, avoid erasing older data if we
     
    612613    /* Being slightly late is fine,
    613614       and has the added benefit of adding some jitter. */
    614     tr_timerAdd( &dht_timer, tosleep, tr_cryptoWeakRandInt( 1000000 ) );
     615    tr_timerAdd( dht_timer, tosleep, tr_cryptoWeakRandInt( 1000000 ) );
    615616}
    616617
  • trunk/libtransmission/tr-udp.c

    r11658 r11659  
    2525#include <assert.h>
    2626
    27 #include <event.h>
     27#include <event2/event.h>
    2828
    2929#include "transmission.h"
     
    158158    if(ss->udp_socket < 0) {
    159159        tr_nerr("UDP", "Couldn't create IPv4 socket");
    160         goto ipv6;
    161     }
    162 
    163     ss->udp_event = tr_new0(struct event, 1);
    164     if(ss->udp_event == NULL) {
    165         tr_nerr("UDP", "Couldn't allocate IPv4 event");
    166         close(ss->udp_socket);
    167         ss->udp_socket = -1;
    168160        goto ipv6;
    169161    }
     
    180172        goto ipv6;
    181173    }
    182 
    183     event_set(ss->udp_event, ss->udp_socket, EV_READ | EV_PERSIST,
    184               event_callback, ss);
     174    ss->udp_event =
     175        event_new(NULL, ss->udp_socket, EV_READ | EV_PERSIST,
     176                  event_callback, ss);
     177    tr_nerr("UDP", "Couldn't allocate IPv4 event");
     178    /* Don't bother recovering for now. */
    185179
    186180 ipv6:
     
    188182        rebind_ipv6(ss, TRUE);
    189183    if(ss->udp6_socket >= 0) {
    190         ss->udp6_event = tr_new0(struct event, 1);
    191         if(ss->udp6_event == NULL) {
     184        ss->udp6_event =
     185            event_new(NULL, ss->udp6_socket, EV_READ | EV_PERSIST,
     186                      event_callback, ss);
     187        if(ss->udp6_event == NULL)
    192188            tr_nerr("UDP", "Couldn't allocate IPv6 event");
    193         } else {
    194             event_set(ss->udp6_event, ss->udp6_socket, EV_READ | EV_PERSIST,
    195                       event_callback, ss);
    196         }
    197189    }
    198190
     
    217209
    218210    if(ss->udp_event) {
    219         event_del(ss->udp_event);
    220         free(ss->udp_event);
     211        event_free(ss->udp_event);
    221212        ss->udp_event = NULL;
    222213    }
     
    228219
    229220    if(ss->udp6_event) {
    230         event_del(ss->udp6_event);
    231         free(ss->udp6_event);
     221        event_free(ss->udp6_event);
    232222        ss->udp6_event = NULL;
    233223    }
Note: See TracChangeset for help on using the changeset viewer.