Changeset 9862


Ignore:
Timestamp:
Jan 4, 2010, 8:06:39 PM (12 years ago)
Author:
charles
Message:

(trunk libT) make sure to restart curl's periodic timer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/web.c

    r9838 r9862  
    1111 */
    1212
     13#include <assert.h>
     14
    1315#include <curl/curl.h>
    1416#include <event.h>
    15 
    16 #include <assert.h>
    1717
    1818#include "transmission.h"
     
    4545#endif
    4646
     47/***
     48****
     49***/
     50
    4751struct tr_web
    4852{
     
    112116    const tr_bool isAnnounce = strstr( task->url, "announce" ) != NULL;
    113117
    114     /* announce and scrape requests have tiny payloads...
    115      * which have very small payloads */
     118    /* announce and scrape requests have tiny payloads. */
    116119    if( isScrape || isAnnounce )
    117120    {
     
    250253tr_multi_perform( tr_web * g, int fd, int curl_what )
    251254{
    252     CURLMcode mcode;
     255    CURLMcode m;
    253256
    254257    dbgmsg( "check_run_count: %d taskCount", g->taskCount );
     
    256259    /* invoke libcurl's processing */
    257260    do
    258         mcode = curl_multi_socket_action( g->multi, fd, curl_what, &g->taskCount );
    259     while( mcode == CURLM_CALL_MULTI_SOCKET );
     261        m = curl_multi_socket_action( g->multi, fd, curl_what, &g->taskCount );
     262    while( m == CURLM_CALL_MULTI_SOCKET );
    260263
    261264    remove_finished_tasks( g );
     
    279282/* CURLMOPT_SOCKETFUNCTION */
    280283static int
    281 sock_cb( CURL * e UNUSED, curl_socket_t fd, int action,
     284sock_cb( CURL * e UNUSED, curl_socket_t fd, int curl_what,
    282285         void * vweb, void * vevent )
    283286{
     
    285288    struct tr_web * web = vweb;
    286289    struct event * io_event = vevent;
    287     dbgmsg( "sock_cb: action %d, fd %d, io_event %p", action, (int)fd, io_event );
    288 
    289     if( ( action == CURL_POLL_NONE ) || ( action & CURL_POLL_REMOVE ) )
     290    dbgmsg( "sock_cb: curl_what %d, fd %d, io_event %p",
     291            curl_what, (int)fd, io_event );
     292
     293    if( ( curl_what == CURL_POLL_NONE ) || ( curl_what & CURL_POLL_REMOVE ) )
    290294    {
    291295        if( io_event != NULL )
     
    301305        }
    302306    }
    303     else if( action & ( CURL_POLL_IN | CURL_POLL_OUT ) )
     307    else if( curl_what & ( CURL_POLL_IN | CURL_POLL_OUT ) )
    304308    {
    305         const short events = EV_PERSIST
    306                            | (( action & CURL_POLL_IN ) ? EV_READ : 0 )
    307                            | (( action & CURL_POLL_OUT ) ? EV_WRITE : 0 );
     309        const short ev_what = EV_PERSIST
     310                           | (( curl_what & CURL_POLL_IN ) ? EV_READ : 0 )
     311                           | (( curl_what & CURL_POLL_OUT ) ? EV_WRITE : 0 );
    308312
    309313        if( io_event != NULL )
     
    315319        }
    316320
    317         dbgmsg( "enabling (libevent %hd, libcurl %d) polling on io_event %p, fd %d",
    318                 events, action, io_event, fd );
    319         event_set( io_event, fd, events, event_cb, web );
     321        dbgmsg( "enabling (libevent %hd, libcurl %d) on io_event %p, fd %d",
     322                ev_what, curl_what, io_event, fd );
     323        event_set( io_event, fd, ev_what, event_cb, web );
    320324        event_add( io_event, NULL );
    321325    }
    322     else assert( 0 && "unhandled action" );
     326    else assert( 0 && "unhandled curl_what" );
    323327
    324328    return 0; /* libcurl documentation: "The callback MUST return 0." */
     
    327331/* libevent says that timer_msec have passed, so wake up libcurl */
    328332static void
    329 libevent_timer_cb( int fd UNUSED, short what UNUSED, void * vg )
    330 {
    331     tr_web * g = vg;
     333libevent_timer_cb( int fd UNUSED, short what UNUSED, void * g )
     334{
    332335    dbgmsg( "libevent timer is done" );
    333336    tr_multi_perform( g, CURL_SOCKET_TIMEOUT, 0 );
     
    347350    if( timer_msec < 1 )
    348351        tr_multi_perform( g, CURL_SOCKET_TIMEOUT, 0 );
     352    else
     353        restart_timer( g );
    349354}
    350355
Note: See TracChangeset for help on using the changeset viewer.