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

Update tr-{dht,udp} to libevent2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.