diff --git a/libtransmission/web.c b/libtransmission/web.c index ac3b2f2cb..cb06cd6e3 100644 --- a/libtransmission/web.c +++ b/libtransmission/web.c @@ -125,10 +125,11 @@ addTask( void * vtask ) tr_free( str ); } - curl_easy_setopt( easy, CURLOPT_DNS_CACHE_TIMEOUT, 3600L ); - curl_easy_setopt( easy, CURLOPT_CONNECTTIMEOUT, 120L ); + curl_easy_setopt( easy, CURLOPT_DNS_CACHE_TIMEOUT, 360L ); + curl_easy_setopt( easy, CURLOPT_CONNECTTIMEOUT, 60L ); curl_easy_setopt( easy, CURLOPT_FOLLOWLOCATION, 1L ); curl_easy_setopt( easy, CURLOPT_FORBID_REUSE, 1L ); + curl_easy_setopt( easy, CURLOPT_MAXREDIRS, 16L ); curl_easy_setopt( easy, CURLOPT_NOSIGNAL, 1L ); curl_easy_setopt( easy, CURLOPT_PRIVATE, task ); curl_easy_setopt( easy, CURLOPT_SSL_VERIFYHOST, 0L ); @@ -199,27 +200,32 @@ task_finish( struct tr_web_task * task, long response_code ) static void remove_finished_tasks( tr_web * g ) { - for( ;; ) - { - int ignored; - CURLMsg * msg = curl_multi_info_read( g->multi, &ignored ); + CURL * easy; - if( msg == NULL ) - { - break; + do + { + CURLMsg * msg; + int msgs_left; + + easy = NULL; + while(( msg = curl_multi_info_read( g->multi, &msgs_left ))) { + if( msg->msg == CURLMSG_DONE ) { + easy = msg->easy_handle; + break; + } } - else if( ( msg->msg == CURLMSG_DONE ) && ( msg->easy_handle != NULL ) ) - { - CURL * easy = msg->easy_handle; + + if( easy ) { long code; struct tr_web_task * task; curl_easy_getinfo( easy, CURLINFO_PRIVATE, (void*)&task ); curl_easy_getinfo( easy, CURLINFO_RESPONSE_CODE, &code ); - task_finish( task, code ); curl_multi_remove_handle( g->multi, easy ); curl_easy_cleanup( easy ); + task_finish( task, code ); } } + while ( easy ); g->prev_running = g->still_running; }