Changeset 12384


Ignore:
Timestamp:
Apr 27, 2011, 5:02:18 PM (10 years ago)
Author:
jordan
Message:

(trunk libT) more heap pruning: build the "cookie_filename" field once when creating the web thread, instead of each time a new tr_web_task is added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/web.c

    r12355 r12384  
    6363struct tr_web
    6464{
     65    bool curl_verbose;
    6566    int close_mode;
    6667    tr_list * tasks;
    6768    tr_lock * taskLock;
     69    char * cookie_filename;
    6870};
    6971
     
    151153
    152154static CURL *
    153 createEasy( tr_session * s, struct tr_web_task * task )
    154 {
     155createEasy( tr_session * s, struct tr_web * web, struct tr_web_task * task )
     156{
     157    bool is_default_value;
    155158    const tr_address * addr;
    156     bool is_default_value;
    157159    CURL * e = curl_easy_init( );
    158     const long verbose = getenv( "TR_CURL_VERBOSE" ) != NULL;
    159     char * cookie_filename = tr_buildPath( s->configDir, "cookies.txt", NULL );
    160160
    161161    task->timeout_secs = getTimeoutFromURL( task );
    162162
    163163    curl_easy_setopt( e, CURLOPT_AUTOREFERER, 1L );
    164     curl_easy_setopt( e, CURLOPT_COOKIEFILE, cookie_filename );
     164    curl_easy_setopt( e, CURLOPT_COOKIEFILE, web->cookie_filename );
    165165    curl_easy_setopt( e, CURLOPT_ENCODING, "gzip;q=1.0, deflate, identity" );
    166166    curl_easy_setopt( e, CURLOPT_FOLLOWLOCATION, 1L );
     
    177177    curl_easy_setopt( e, CURLOPT_URL, task->url );
    178178    curl_easy_setopt( e, CURLOPT_USERAGENT, TR_NAME "/" SHORT_VERSION_STRING );
    179     curl_easy_setopt( e, CURLOPT_VERBOSE, verbose );
     179    curl_easy_setopt( e, CURLOPT_VERBOSE, (long)(web->curl_verbose?1:0) );
    180180    curl_easy_setopt( e, CURLOPT_WRITEDATA, task );
    181181    curl_easy_setopt( e, CURLOPT_WRITEFUNCTION, writeFunc );
     
    195195        s->curl_easy_config_func( s, e, task->url, s->curl_easy_config_user_data );
    196196
    197     tr_free( cookie_filename );
    198197    return e;
    199198}
     
    319318    web->taskLock = tr_lockNew( );
    320319    web->tasks = NULL;
     320    web->curl_verbose = getenv( "TR_CURL_VERBOSE" ) != NULL;
     321    web->cookie_filename = tr_buildPath( session->configDir, "cookies.txt", NULL );
     322
    321323    multi = curl_multi_init( );
    322324    session->web = web;
     
    339341        {
    340342            dbgmsg( "adding task to curl: [%s]", task->url );
    341             curl_multi_add_handle( multi, createEasy( session, task ));
     343            curl_multi_add_handle( multi, createEasy( session, web, task ));
    342344            /*fprintf( stderr, "adding a task.. taskCount is now %d\n", taskCount );*/
    343345            ++taskCount;
     
    422424    curl_multi_cleanup( multi );
    423425    tr_lockFree( web->taskLock );
     426    tr_free( web->cookie_filename );
    424427    tr_free( web );
    425428    session->web = NULL;
Note: See TracChangeset for help on using the changeset viewer.