Changeset 9072


Ignore:
Timestamp:
Sep 8, 2009, 7:04:44 PM (13 years ago)
Author:
charles
Message:

(1.7x libT) backport r9065 for ticket #1844

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.7x/libtransmission/web.c

    r9058 r9072  
    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
     
    389402
    390403    /* invoke libcurl's processing */
    391 #ifdef USE_CURL_MULTI_SOCKET_ACTION
    392     do {
    393         dbgmsg( "calling curl_multi_socket_action..." );
    394         mcode = curl_multi_socket_action( g->multi, fd, 0, &g->still_running );
    395         fd = CURL_SOCKET_TIMEOUT;
    396         dbgmsg( "done calling curl_multi_socket_action..." );
    397     } while( mcode == CURLM_CALL_MULTI_SOCKET );
    398 #else
    399     do {
    400         dbgmsg( "calling curl_multi_perform..." );
    401         mcode = curl_multi_perform( g->multi, &g->still_running );
    402         dbgmsg( "done calling curl_multi_perform..." );
    403     } while( mcode == CURLM_CALL_MULTI_PERFORM );
    404 #endif
     404    if( useCurlMultiSocketAction( ) )
     405    {
     406        do {
     407            dbgmsg( "calling curl_multi_socket_action..." );
     408            mcode = curl_multi_socket_action( g->multi, fd, 0, &g->still_running );
     409            fd = CURL_SOCKET_TIMEOUT;
     410            dbgmsg( "done calling curl_multi_socket_action..." );
     411        } while( mcode == CURLM_CALL_MULTI_SOCKET );
     412    }
     413    else
     414    {
     415        do {
     416            dbgmsg( "calling curl_multi_perform..." );
     417            mcode = curl_multi_perform( g->multi, &g->still_running );
     418            dbgmsg( "done calling curl_multi_perform..." );
     419        } while( mcode == CURLM_CALL_MULTI_PERFORM );
     420    }
    405421    tr_assert( mcode == CURLM_OK, "curl_multi_perform() failed: %d (%s)", mcode, curl_multi_strerror( mcode ) );
    406422    if( mcode != CURLM_OK )
Note: See TracChangeset for help on using the changeset viewer.