1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 01:03:01 +00:00

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

This commit is contained in:
Charles Kerr 2009-02-18 16:16:24 +00:00
parent d5411c14e8
commit 491a6ac63d

View file

@ -26,6 +26,13 @@
#include "utils.h" #include "utils.h"
#include "web.h" #include "web.h"
/* Use curl_multi_socket_action() instead of curl_multi_perform()
if libcurl >= 7.18.2. See http://trac.transmissionbt.com/ticket/1844 */
#if LIBCURL_VERSION_NUM >= 0x071202
#define USE_CURL_MULTI_SOCKET_ACTION
#endif
enum enum
{ {
/* arbitrary number */ /* arbitrary number */
@ -336,7 +343,7 @@ web_close( tr_web * g )
and no tasks remain. callers must not reference their g pointer and no tasks remain. callers must not reference their g pointer
after calling this function */ after calling this function */
static void static void
tr_multi_perform( tr_web * g ) tr_multi_perform( tr_web * g, int fd )
{ {
int closed = FALSE; int closed = FALSE;
CURLMcode mcode; CURLMcode mcode;
@ -345,11 +352,20 @@ tr_multi_perform( tr_web * g )
g->prev_running, g->still_running ); g->prev_running, g->still_running );
/* invoke libcurl's processing */ /* invoke libcurl's processing */
#ifdef USE_CURL_MULTI_SOCKET_ACTION
do {
dbgmsg( "calling curl_multi_socket_action..." );
mcode = curl_multi_socket_action( g->multi, fd, 0, &g->still_running );
fd = CURL_SOCKET_TIMEOUT;
dbgmsg( "done calling curl_multi_socket_action..." );
} while( mcode == CURLM_CALL_MULTI_SOCKET );
#else
do { do {
dbgmsg( "calling curl_multi_perform..." ); dbgmsg( "calling curl_multi_perform..." );
mcode = curl_multi_perform( g->multi, &g->still_running ); mcode = curl_multi_perform( g->multi, &g->still_running );
dbgmsg( "done calling curl_multi_perform..." ); dbgmsg( "done calling curl_multi_perform..." );
} while( mcode == CURLM_CALL_MULTI_PERFORM ); } while( mcode == CURLM_CALL_MULTI_PERFORM );
#endif
tr_assert( mcode == CURLM_OK, "curl_multi_perform() failed: %d (%s)", mcode, curl_multi_strerror( mcode ) ); tr_assert( mcode == CURLM_OK, "curl_multi_perform() failed: %d (%s)", mcode, curl_multi_strerror( mcode ) );
if( mcode != CURLM_OK ) if( mcode != CURLM_OK )
tr_err( "%s", curl_multi_strerror( mcode ) ); tr_err( "%s", curl_multi_strerror( mcode ) );
@ -371,9 +387,9 @@ tr_multi_perform( tr_web * g )
/* libevent says that sock is ready to be processed, so wake up libcurl */ /* libevent says that sock is ready to be processed, so wake up libcurl */
static void static void
event_cb( int fd UNUSED, short kind UNUSED, void * g ) event_cb( int fd, short kind UNUSED, void * g )
{ {
tr_multi_perform( g ); tr_multi_perform( g, fd );
} }
/* libevent says that timer_ms have passed, so wake up libcurl */ /* libevent says that timer_ms have passed, so wake up libcurl */
@ -381,7 +397,7 @@ static void
timer_cb( int socket UNUSED, short action UNUSED, void * g ) timer_cb( int socket UNUSED, short action UNUSED, void * g )
{ {
dbgmsg( "libevent timer is done" ); dbgmsg( "libevent timer is done" );
tr_multi_perform( g ); tr_multi_perform( g, CURL_SOCKET_TIMEOUT );
} }
/* CURLMOPT_SOCKETFUNCTION */ /* CURLMOPT_SOCKETFUNCTION */