Ignore:
Timestamp:
Sep 8, 2009, 5:18:46 AM (13 years ago)
Author:
charles
Message:

decide at runtime, rather than compile time, whether to use curl_multi_action

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/web.c

    r8986 r9065  
    2828#include "web.h"
    2929
    30 /* Use curl_multi_socket_action() instead of curl_multi_perform()
    31    if libcurl >= 7.18.2.  See http://trac.transmissionbt.com/ticket/1844 */
    32 #if LIBCURL_VERSION_NUM >= 0x071202
    33     #define USE_CURL_MULTI_SOCKET_ACTION
    34 #endif
     30static tr_bool
     31useCurlMultiSocketAction( void )
     32{
     33    static tr_bool tested = FALSE;
     34    static tr_bool useMultiSocketAction;
     35
     36    if( !tested )
     37    {
     38        curl_version_info_data * data = curl_version_info( CURLVERSION_NOW );
     39        tr_inf( "Using libcurl %s", data->version );
     40        /* Use curl_multi_socket_action() instead of curl_multi_perform()
     41         * if libcurl >= 7.18.2.  See http://trac.transmissionbt.com/ticket/1844 */
     42        useMultiSocketAction = data->version_num >= 0x071202;
     43        tested = TRUE;
     44    }
     45
     46    return useMultiSocketAction;
     47}
    3548
    3649
     
    386399
    387400    /* invoke libcurl's processing */
    388 #ifdef USE_CURL_MULTI_SOCKET_ACTION
    389     do {
    390         dbgmsg( "calling curl_multi_socket_action..." );
    391         mcode = curl_multi_socket_action( g->multi, fd, 0, &g->still_running );
    392         fd = CURL_SOCKET_TIMEOUT;
    393         dbgmsg( "done calling curl_multi_socket_action..." );
    394     } while( mcode == CURLM_CALL_MULTI_SOCKET );
    395 #else
    396     do {
    397         dbgmsg( "calling curl_multi_perform..." );
    398         mcode = curl_multi_perform( g->multi, &g->still_running );
    399         dbgmsg( "done calling curl_multi_perform..." );
    400     } while( mcode == CURLM_CALL_MULTI_PERFORM );
    401 #endif
     401    if( useCurlMultiSocketAction( ) )
     402    {
     403        do {
     404            dbgmsg( "calling curl_multi_socket_action..." );
     405            mcode = curl_multi_socket_action( g->multi, fd, 0, &g->still_running );
     406            fd = CURL_SOCKET_TIMEOUT;
     407            dbgmsg( "done calling curl_multi_socket_action..." );
     408        } while( mcode == CURLM_CALL_MULTI_SOCKET );
     409    }
     410    else
     411    {
     412        do {
     413            dbgmsg( "calling curl_multi_perform..." );
     414            mcode = curl_multi_perform( g->multi, &g->still_running );
     415            dbgmsg( "done calling curl_multi_perform..." );
     416        } while( mcode == CURLM_CALL_MULTI_PERFORM );
     417    }
    402418    tr_assert( mcode == CURLM_OK, "curl_multi_perform() failed: %d (%s)", mcode, curl_multi_strerror( mcode ) );
    403419    if( mcode != CURLM_OK )
Note: See TracChangeset for help on using the changeset viewer.