Changeset 9837


Ignore:
Timestamp:
Dec 28, 2009, 11:29:59 PM (12 years ago)
Author:
charles
Message:

(trunk libT) #2416 "crash in event_queue_insert" -- instead of freeing libevent's event objects, pool and reuse them. *sigh*

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/web.c

    r9835 r9837  
    5656    tr_address addr;
    5757    struct event timer_event;
    58     tr_list * freeme;
     58    tr_list * active_events;
     59    tr_list * inactive_events;
    5960};
    6061
    6162static void
     63event_list_node_free( void * event )
     64{
     65    event_del( event );
     66    tr_free( event );
     67}
     68
     69static void
    6270web_free( tr_web * g )
    6371{
    6472    curl_multi_cleanup( g->multi );
    65     tr_list_free( &g->freeme, tr_free );
     73    tr_list_free( &g->active_events, event_list_node_free );
     74    tr_list_free( &g->inactive_events, event_list_node_free );
    6675    evtimer_del( &g->timer_event );
    6776    memset( g, TR_MEMORY_TRASH, sizeof( struct tr_web ) );
     
    295304        {
    296305            event_del( io_event );
    297             tr_list_append( &web->freeme, io_event );
     306            tr_list_remove_data( &web->active_events, io_event );
     307            tr_list_append( &web->inactive_events, io_event );
    298308            curl_multi_assign( web->multi, fd, NULL );
    299309            /*fprintf( stderr, "-1 io_events to %d\n", --num_events );*/
     
    309319            event_del( io_event );
    310320        else {
    311             io_event = tr_new0( struct event, 1 );
     321            io_event = tr_list_pop_front( &web->inactive_events );
     322            if( io_event == NULL )
     323                io_event = tr_new0( struct event, 1 );
    312324            curl_multi_assign( web->multi, fd, io_event );
     325            tr_list_append( &web->active_events, io_event );
    313326            /*fprintf( stderr, "+1 io_events to %d\n", ++num_events );*/
    314327        }
     
    329342{
    330343    tr_web * g = vg;
    331     tr_list_free( &g->freeme, tr_free );
    332344    dbgmsg( "libevent timer is done" );
    333345    tr_multi_perform( g, CURL_SOCKET_TIMEOUT, 0 );
Note: See TracChangeset for help on using the changeset viewer.