Changeset 10013


Ignore:
Timestamp:
Jan 25, 2010, 4:24:48 AM (12 years ago)
Author:
charles
Message:

(trunk libT) extend the lifespan of the cached DNS entries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/web.c

    r10012 r10013  
    3131
    3232    DEFAULT_TIMER_MSEC = 1500 /* arbitrary */
     33
     34    MIN_DNS_CACHE_TIME = 60 * 60 * 24
    3335};
    3436
     
    160162
    161163    if( item != NULL )
    162         dbgmsg( "found cached dns entry for \"%s\": %s", host, item->resolved_host );
     164        dbgmsg( "found cached dns entry for \"%s\": %s",
     165                host, item->resolved_host );
    163166
    164167    return item ? item->resolved_host : NULL;
     
    166169
    167170static const char*
    168 dns_set_cached_host( struct tr_web_task * task, const char * host, const char * resolved, int ttl )
     171dns_set_cached_host( struct tr_web_task * task, const char * host,
     172                     const char * resolved, int ttl )
    169173{
    170174    char * ret = NULL;
     
    175179    assert( resolved != NULL );
    176180    assert( ttl >= 0 );
     181
     182    ttl = MAX( MIN_DNS_CACHE_TIME, ttl );
    177183
    178184    g = task->session->web;
     
    315321        curl_easy_setopt( e, CURLOPT_WRITEDATA, task );
    316322        curl_easy_setopt( e, CURLOPT_WRITEFUNCTION, writeFunc );
    317         curl_easy_setopt( e, CURLOPT_DNS_CACHE_TIMEOUT, 1800L );
     323        curl_easy_setopt( e, CURLOPT_DNS_CACHE_TIMEOUT, MIN_DNS_CACHE_TIME );
    318324        curl_easy_setopt( e, CURLOPT_FOLLOWLOCATION, 1L );
    319325        curl_easy_setopt( e, CURLOPT_AUTOREFERER, 1L );
Note: See TracChangeset for help on using the changeset viewer.