Ignore:
Timestamp:
Jul 29, 2008, 6:53:41 PM (13 years ago)
Author:
charles
Message:

#1117: crash on exit in curl_multi_socket_action()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/web.c

    r6414 r6417  
    1818
    1919#include "transmission.h"
     20#include "list.h"
    2021#include "trevent.h"
    2122#include "utils.h"
     
    2627struct tr_web
    2728{
    28     unsigned int dying     : 1;
    29     unsigned int running   : 1;
    3029    int remain;
    3130    CURLM * cm;
    3231    tr_session * session;
     32    tr_list * socket_events;
    3333    struct event timer;
    3434};
     
    182182}
    183183
    184 static void
    185 webDestroy( tr_web * web )
    186 {
    187     dbgmsg( "deleting web timer" );
    188     assert( !web->running );
    189     evtimer_del( &web->timer );
    190     curl_multi_cleanup( web->cm );
    191     tr_free( web );
    192 }
    193 
    194184/* libevent says that sock is ready to be processed, so wake up libcurl */
    195185static void
     
    239229    else {
    240230        ev = tr_new0( struct event, 1 );
     231        tr_list_prepend( &web->socket_events, ev );
    241232        curl_multi_assign( web->cm, sock, ev );
    242233    }
     
    255246        case CURL_POLL_OUT: events |= EV_WRITE; break;
    256247        case CURL_POLL_INOUT: events |= EV_READ|EV_WRITE; break;
    257         case CURL_POLL_REMOVE: tr_free( ev ); /* fallthrough */
     248        case CURL_POLL_REMOVE: tr_list_remove_data( &web->socket_events, ev );
     249                               tr_free( ev );
     250                               /* fallthrough */
    258251        case CURL_POLL_NONE: return 0;
    259252        default: tr_err( "Unknown socket action %d", action ); return -1;
     
    288281    tr_web * web = vweb;
    289282    struct timeval timeout = tr_timevalMsec( timeout_ms );
    290     evtimer_add( &web->timer, &timeout );
     283    timeout_add( &web->timer, &timeout );
    291284}
    292285
     
    310303    web->session = session;
    311304
    312     evtimer_set( &web->timer, timeout_callback, web );
     305    timeout_set( &web->timer, timeout_callback, web );
    313306    curl_multi_setopt( web->cm, CURLMOPT_SOCKETDATA, web );
    314307    curl_multi_setopt( web->cm, CURLMOPT_SOCKETFUNCTION, socket_callback );
     
    319312}
    320313
     314static void
     315event_del_and_free( void * e )
     316{
     317    event_del( e );
     318    tr_free( e );
     319}
     320
    321321void
    322322tr_webClose( tr_web ** web_in )
     
    325325    *web_in = NULL;
    326326
    327     if( !web->running )
    328         webDestroy( web );
    329     else
    330         web->dying = 1;
     327    timeout_del( &web->timer );
     328    tr_list_free( &web->socket_events, event_del_and_free );
     329    curl_multi_cleanup( web->cm );
     330    tr_free( web );
    331331}
    332332
Note: See TracChangeset for help on using the changeset viewer.