Changeset 7906


Ignore:
Timestamp:
Feb 18, 2009, 4:16:26 PM (13 years ago)
Author:
charles
Message:

(1.5x libT) #1844: Prefer curl_multi_socket_action() to curl_multi_perform() in modern versions of libcurl

File:
1 edited

Legend:

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

    r7873 r7906  
    2626#include "utils.h"
    2727#include "web.h"
     28
     29/* Use curl_multi_socket_action() instead of curl_multi_perform()
     30   if libcurl >= 7.18.2.  See http://trac.transmissionbt.com/ticket/1844 */
     31#if LIBCURL_VERSION_NUM >= 0x071202
     32    #define USE_CURL_MULTI_SOCKET_ACTION
     33#endif
     34
    2835
    2936enum
     
    337344   after calling this function */
    338345static void
    339 tr_multi_perform( tr_web * g )
     346tr_multi_perform( tr_web * g, int fd )
    340347{
    341348    int closed = FALSE;
     
    346353
    347354    /* invoke libcurl's processing */
     355#ifdef USE_CURL_MULTI_SOCKET_ACTION
     356    do {
     357        dbgmsg( "calling curl_multi_socket_action..." );
     358        mcode = curl_multi_socket_action( g->multi, fd, 0, &g->still_running );
     359        fd = CURL_SOCKET_TIMEOUT;
     360        dbgmsg( "done calling curl_multi_socket_action..." );
     361    } while( mcode == CURLM_CALL_MULTI_SOCKET );
     362#else
    348363    do {
    349364        dbgmsg( "calling curl_multi_perform..." );
     
    351366        dbgmsg( "done calling curl_multi_perform..." );
    352367    } while( mcode == CURLM_CALL_MULTI_PERFORM );
     368#endif
    353369    tr_assert( mcode == CURLM_OK, "curl_multi_perform() failed: %d (%s)", mcode, curl_multi_strerror( mcode ) );
    354370    if( mcode != CURLM_OK )
     
    372388/* libevent says that sock is ready to be processed, so wake up libcurl */
    373389static void
    374 event_cb( int fd UNUSED, short kind UNUSED, void * g )
    375 {
    376     tr_multi_perform( g );
     390event_cb( int fd, short kind UNUSED, void * g )
     391{
     392    tr_multi_perform( g, fd );
    377393}
    378394
     
    382398{
    383399    dbgmsg( "libevent timer is done" );
    384     tr_multi_perform( g );
     400    tr_multi_perform( g, CURL_SOCKET_TIMEOUT );
    385401}
    386402
Note: See TracChangeset for help on using the changeset viewer.