Changeset 2836


Ignore:
Timestamp:
Aug 18, 2007, 6:59:20 AM (15 years ago)
Author:
charles
Message:

push event_del() through the libevent pipe too.

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/timer.c

    r2829 r2836  
    2828struct timer_node
    2929{
    30     struct event event;
     30    tr_handle_t * handle;
     31    struct event * event;
    3132    tr_timer_func * func;
    3233    void * user_data;
     
    4849    if( node->free_func != NULL )
    4950        (node->free_func)( node->user_data );
    50     event_del( &node->event );
     51    tr_event_del( node->handle, node->event );
    5152    tr_free( node );
    5253}
     
    7576        unref( node, 2 );
    7677    else {
    77         timeout_add( &node->event, &node->tv );
     78        timeout_add( node->event, &node->tv );
    7879        unref( node, 1 );
    7980    }
     
    9596
    9697    node = tr_new( struct timer_node, 1 );
     98    node->handle = handle;
     99    node->event = tr_new0( struct event, 1 );
    97100    node->func = func;
    98101    node->user_data = user_data;
     
    101104    node->tv.tv_sec  = microseconds / 1000000;
    102105    node->tv.tv_usec = microseconds % 1000000;
    103     timeout_set( &node->event, timerCB, node );
    104     tr_event_add( handle, &node->event, &node->tv );
     106    timeout_set( node->event, timerCB, node );
     107    tr_event_add( handle, node->event, &node->tv );
    105108    return node;
    106109}
  • trunk/libtransmission/trevent.c

    r2829 r2836  
    6969    enum evhttp_cmd_type type;
    7070    const char * uri;
    71     static char * buf = NULL;
    7271
    7372#ifdef DEBUG
    7473    fprintf( stderr, "reading...reads: [%d] writes: [%d]\n", ++reads, writes );
    7574#endif
    76 
    77     if( !buf )
    78          buf = tr_new0( char, sizeof(void*) );
    7975
    8076    ch = '\0';
     
    8985    else switch( ch )
    9086    {
     87        case 'd': /* event_del */
     88            read( fd, &event, sizeof(struct event*) );
     89            tr_dbg( "read del event from pipe: event is %p", event );
     90            event_del( event );
     91            break;
     92
    9193        case 'e': /* event_add */
    92             event = tr_new0( struct event, 1 );
    93             read( fd, event, sizeof(struct event) );
     94            read( fd, &event, sizeof(struct event*) );
    9495            read( fd, &interval, sizeof(struct timeval) );
    9596            tr_dbg( "read event from pipe: event.ev_arg is %p", event->ev_arg );
     
    151152
    152153void
    153 tr_event_add (tr_handle_t    * handle,
     154tr_event_add( tr_handle_t    * handle,
    154155              struct event   * event,
    155156              struct timeval * interval )
     
    165166#endif
    166167    write( fd, &ch, 1 );
    167     write( fd, event, sizeof(struct event) );
     168    write( fd, &event, sizeof(struct event*) );
    168169    write( fd, interval, sizeof(struct timeval) );
     170    tr_lockUnlock( lock );
     171}
     172
     173void
     174tr_event_del( tr_handle_t    * handle,
     175              struct event   * event )
     176{
     177    const char ch = 'd';
     178    int fd = handle->events->fds[1];
     179    tr_lock_t * lock = handle->events->lock;
     180
     181    tr_lockLock( lock );
     182    tr_dbg( "writing event to pipe: del event %p", event );
     183#ifdef DEBUG
     184    fprintf( stderr, "reads: [%d] writes: [%d]\n", reads, ++writes );
     185#endif
     186    write( fd, &ch, 1 );
     187    write( fd, &event, sizeof(struct event*) );
    169188    tr_lockUnlock( lock );
    170189}
  • trunk/libtransmission/trevent.h

    r2829 r2836  
    2626struct evhttp_connection;
    2727
    28 extern void  tr_event_add( struct tr_handle_s  * tr_handle,
    29                            struct event        * event,
    30                            struct timeval      * interval );
     28void  tr_event_add( struct tr_handle_s  * tr_handle,
     29                    struct event        * event,
     30                    struct timeval      * interval );
    3131
    32 extern void tr_evhttp_make_request (struct tr_handle_s        * tr_handle,
    33                                     struct evhttp_connection  * evcon,
    34                                     struct evhttp_request     * req,
    35                                     enum evhttp_cmd_type        type,
    36                                     const char                * uri);
     32void  tr_event_del( struct tr_handle_s  * tr_handle,
     33                    struct event        * event );
     34
     35void tr_evhttp_make_request (struct tr_handle_s        * tr_handle,
     36                             struct evhttp_connection  * evcon,
     37                             struct evhttp_request     * req,
     38                             enum evhttp_cmd_type        type,
     39                             const char                * uri);
    3740
    3841#endif
Note: See TracChangeset for help on using the changeset viewer.