Changeset 5712


Ignore:
Timestamp:
Apr 27, 2008, 6:27:32 PM (14 years ago)
Author:
charles
Message:

fix one of the crash-on-shutdown bugs reported by Gimp_

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/web.c

    r5711 r5712  
    124124{
    125125    struct tr_web_task * task = vtask;
    126     struct tr_web * web = task->session->web;
    127     CURL * ch;
    128 
    129     ++web->remain;
    130     dbgmsg( "adding task #%lu [%s] (%d remain)", task->tag, task->url, web->remain );
    131 
    132     ch = curl_easy_init( );
    133     curl_easy_setopt( ch, CURLOPT_PRIVATE, task );
    134     curl_easy_setopt( ch, CURLOPT_URL, task->url );
    135     curl_easy_setopt( ch, CURLOPT_WRITEFUNCTION, writeFunc );
    136     curl_easy_setopt( ch, CURLOPT_WRITEDATA, task );
    137     curl_easy_setopt( ch, CURLOPT_USERAGENT, TR_NAME "/" LONG_VERSION_STRING );
    138     curl_easy_setopt( ch, CURLOPT_SSL_VERIFYPEER, 0 );
    139     curl_easy_setopt( ch, CURLOPT_FORBID_REUSE, 1 );
    140     curl_easy_setopt( ch, CURLOPT_NOSIGNAL, 1 );
    141     curl_easy_setopt( ch, CURLOPT_FOLLOWLOCATION, 1 );
    142     curl_easy_setopt( ch, CURLOPT_MAXREDIRS, 5 );
    143     curl_easy_setopt( ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
    144     curl_easy_setopt( ch, CURLOPT_ENCODING, "" );
    145     curl_multi_add_handle( web->cm, ch );
    146 
    147     pump( web );
     126
     127    if( task->session && task->session->web )
     128    {
     129        struct tr_web * web = task->session->web;
     130        CURL * ch;
     131
     132        ++web->remain;
     133        dbgmsg( "adding task #%lu [%s] (%d remain)", task->tag, task->url, web->remain );
     134
     135        ch = curl_easy_init( );
     136        curl_easy_setopt( ch, CURLOPT_PRIVATE, task );
     137        curl_easy_setopt( ch, CURLOPT_URL, task->url );
     138        curl_easy_setopt( ch, CURLOPT_WRITEFUNCTION, writeFunc );
     139        curl_easy_setopt( ch, CURLOPT_WRITEDATA, task );
     140        curl_easy_setopt( ch, CURLOPT_USERAGENT, TR_NAME "/" LONG_VERSION_STRING );
     141        curl_easy_setopt( ch, CURLOPT_SSL_VERIFYPEER, 0 );
     142        curl_easy_setopt( ch, CURLOPT_FORBID_REUSE, 1 );
     143        curl_easy_setopt( ch, CURLOPT_NOSIGNAL, 1 );
     144        curl_easy_setopt( ch, CURLOPT_FOLLOWLOCATION, 1 );
     145        curl_easy_setopt( ch, CURLOPT_MAXREDIRS, 5 );
     146        curl_easy_setopt( ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
     147        curl_easy_setopt( ch, CURLOPT_ENCODING, "" );
     148        curl_multi_add_handle( web->cm, ch );
     149
     150        pump( web );
     151    }
    148152}
    149153
     
    154158           void               * done_func_user_data )
    155159{
    156     static unsigned long tag = 0;
    157     struct tr_web_task * task;
    158 
    159     task = tr_new0( struct tr_web_task, 1 );
    160     task->session = session;
    161     task->url = tr_strdup( url );
    162     task->done_func = done_func;
    163     task->done_func_user_data = done_func_user_data;
    164     task->tag = ++tag;
    165     task->response = evbuffer_new( );
    166 
    167     tr_runInEventThread( session, addTask, task );
     160    if( session->web )
     161    {
     162        static unsigned long tag = 0;
     163        struct tr_web_task * task;
     164
     165        task = tr_new0( struct tr_web_task, 1 );
     166        task->session = session;
     167        task->url = tr_strdup( url );
     168        task->done_func = done_func;
     169        task->done_func_user_data = done_func_user_data;
     170        task->tag = ++tag;
     171        task->response = evbuffer_new( );
     172
     173        tr_runInEventThread( session, addTask, task );
     174    }
    168175}
    169176
Note: See TracChangeset for help on using the changeset viewer.