Changeset 10602


Ignore:
Timestamp:
May 1, 2010, 2:19:45 PM (8 years ago)
Author:
charles
Message:

(1.9x libT) backport r10535 and r10554 for #3117 "Tracker queries don't honor bind-address-ipv4"

Location:
branches/1.9x/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/1.9x/libtransmission/session.c

    r10601 r10602  
    215215tr_sessionGetPublicAddress( const tr_session * session, int tr_af_type )
    216216{
     217    const struct tr_bindinfo * bindinfo;
     218
    217219    switch( tr_af_type )
    218220    {
    219         case TR_AF_INET: return &session->public_ipv4->addr;
    220         case TR_AF_INET6: return &session->public_ipv6->addr; break;
    221         default: return NULL;
    222     }
     221        case TR_AF_INET:  bindinfo = session->public_ipv4; break;
     222        case TR_AF_INET6: bindinfo = session->public_ipv6; break;
     223        default:          bindinfo = NULL;                 break;
     224    }
     225
     226    return bindinfo ? &bindinfo->addr : NULL;
    223227}
    224228
     
    708712    b.socket = -1;
    709713    session->public_ipv4 = tr_memdup( &b, sizeof( struct tr_bindinfo ) );
    710     tr_webSetInterface( session, &session->public_ipv4->addr );
    711714
    712715    str = TR_PREFS_KEY_BIND_ADDRESS_IPV6;
  • branches/1.9x/libtransmission/web.c

    r10572 r10602  
    5656{
    5757    int close_mode;
    58     tr_bool haveAddr;
    5958    tr_list * tasks;
    6059    tr_lock * taskLock;
    61     tr_address addr;
    6260};
    6361
     
    140138
    141139static CURL *
    142 createEasy( tr_session * s, struct tr_web * w, struct tr_web_task * task )
    143 {
     140createEasy( tr_session * s, struct tr_web_task * task )
     141{
     142    const tr_address * addr;
    144143    CURL * e = curl_easy_init( );
    145144    const long verbose = getenv( "TR_CURL_VERBOSE" ) != NULL;
     
    178177    curl_easy_setopt( e, CURLOPT_WRITEDATA, task );
    179178    curl_easy_setopt( e, CURLOPT_WRITEFUNCTION, writeFunc );
    180     if( w->haveAddr )
    181         curl_easy_setopt( e, CURLOPT_INTERFACE, tr_ntop_non_ts( &w->addr ) );
     179
     180    if(( addr = tr_sessionGetPublicAddress( s, TR_AF_INET )))
     181        curl_easy_setopt( e, CURLOPT_INTERFACE, tr_ntop_non_ts( addr ) );
     182
    182183    if( task->range )
    183184        curl_easy_setopt( e, CURLOPT_RANGE, task->range );
     
    236237}
    237238
    238 void
    239 tr_webSetInterface( tr_session * session, const tr_address * addr )
    240 {
    241     struct tr_web * web = session->web;
    242 
    243     if( web != NULL )
    244         if(( web->haveAddr = ( addr != NULL )))
    245             web->addr = *addr;
    246 }
    247 
    248239static void
    249240tr_webThreadFunc( void * vsession )
     
    283274        while(( task = tr_list_pop_front( &web->tasks )))
    284275        {
    285             curl_multi_add_handle( multi, createEasy( session, web, task ));
     276            curl_multi_add_handle( multi, createEasy( session, task ));
    286277            /*fprintf( stderr, "adding a task.. taskCount is now %d\n", taskCount );*/
    287278            ++taskCount;
  • branches/1.9x/libtransmission/web.h

    r10303 r10602  
    2727void tr_webClose( tr_session * session, tr_web_close_mode close_mode );
    2828
    29 void tr_webSetInterface( tr_session * session, const struct tr_address * addr );
    30 
    3129typedef void ( tr_web_done_func )( tr_session       * session,
    3230                                   long               response_code,
Note: See TracChangeset for help on using the changeset viewer.