Changeset 10019


Ignore:
Timestamp:
Jan 26, 2010, 7:22:50 AM (12 years ago)
Author:
charles
Message:

(trunk libT) #2792 "since 1.80 update downloads failing" -- try to handle non-resolving tracker addresses without blocking in curl

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-msgs.c

    r10011 r10019  
    17061706        int estimatedBlocksInPeriod;
    17071707        double rate;
    1708         const int floor = 8;
     1708        const int floor = 4;
    17091709        const int seconds = REQUEST_BUF_SECS;
    17101710
  • trunk/libtransmission/web.c

    r10014 r10019  
    100100    CURL * easy;
    101101    CURLM * multi;
     102    tr_bool timer_event_isSet;
    102103};
    103104
     
    107108    if( task->slist != NULL )
    108109        curl_slist_free_all( task->slist );
    109     evtimer_del( &task->timer_event );
     110    if( task->timer_event_isSet )
     111        evtimer_del( &task->timer_event );
    110112    evbuffer_free( task->response );
    111113    tr_free( task->host );
     
    247249
    248250static void task_timeout_cb( int fd UNUSED, short what UNUSED, void * task );
     251static void task_finish( struct tr_web_task * task, long response_code );
    249252
    250253static void
     
    254257    const tr_session * session = task->session;
    255258
    256     if( session && session->web )
     259    if( ( session == NULL ) || ( session->web == NULL ) )
     260        return;
     261
     262    if( task->resolved_host == NULL )
     263    {
     264        dbgmsg( "couldn't resolve host for \"%s\"... task failed", task->url );
     265        task_finish( task, 0 );
     266    }
     267    else
    257268    {
    258269        CURL * e = curl_easy_init( );
     
    263274        char * url = NULL;
    264275
    265         /* If we've got a resolved host, insert it into the URL: replace
    266          * "http://www.craptrackular.org/announce?key=val&key2=..." with
    267          * "http://127.0.0.1/announce?key=val&key2=..."
    268          * so that curl's DNS won't block */
    269         if( task->resolved_host != NULL )
     276        /* insert the resolved host into the URL s.t. curl's DNS won't block
     277         * even if -- like on most OSes -- it wasn't built with C-Ares :(
     278         * "http://www.craptrackular.org/announce?key=val&key2=..." becomes
     279         * "http://127.0.0.1/announce?key=val&key2=..." */
    270280        {
    271281            char * host;
     
    280290            evbuffer_free( buf );
    281291
     292            /* Manually add a Host: argument that refers to the true URL */
    282293            if( ( ( task->port <= 0 ) ) ||
    283294                ( ( task->port == 80 ) && !strncmp( task->url, "http://", 7 ) ) ||
     
    313324        /* use our own timeout instead of CURLOPT_TIMEOUT because the latter
    314325         * doesn't play nicely with curl_multi.  See curl bug #2501457 */
     326        task->timer_event_isSet = TRUE;
    315327        evtimer_set( &task->timer_event, task_timeout_cb, task );
    316328        tr_timerAdd( &task->timer_event, timeout, 0 );
Note: See TracChangeset for help on using the changeset viewer.