Changeset 9754


Ignore:
Timestamp:
Dec 14, 2009, 2:25:22 PM (12 years ago)
Author:
charles
Message:

(trunk libT) keep simplifying web.c... is there anything left to strip out?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/web.c

    r9750 r9754  
    2626    DEFAULT_TIMER_MSEC = 1500 /* arbitrary */
    2727};
    28 
    29 static tr_bool tr_multi_perform( tr_web * g, int fd );
    3028
    3129#if 0
     
    4644{
    4745    tr_bool closing;
     46    tr_bool haveAddr;
    4847    int taskCount;
    4948    long timer_msec;
    5049    CURLM * multi;
    5150    tr_session * session;
    52     tr_bool haveAddr;
    5351    tr_address addr;
    5452    struct event timer_event;
     
    5654
    5755static void
    58 web_close( tr_web * g )
     56web_free( tr_web * g )
    5957{
    6058    curl_multi_cleanup( g->multi );
     
    194192        mcode = curl_multi_add_handle( web->multi, e );
    195193        ++web->taskCount;
    196         /*tr_multi_perform( web, CURL_SOCKET_TIMEOUT );*/
    197194    }
    198195}
     
    244241}
    245242
    246 static tr_bool
     243static void
    247244tr_multi_perform( tr_web * g, int fd )
    248245{
    249246    CURLMcode mcode;
    250     tr_bool closed = FALSE;
    251247
    252248    dbgmsg( "check_run_count: %d taskCount", g->taskCount );
    253249
    254250    /* invoke libcurl's processing */
    255     do {
     251    do
    256252        mcode = curl_multi_socket_action( g->multi, fd, 0, &g->taskCount );
    257     } while( mcode == CURLM_CALL_MULTI_SOCKET );
     253    while( mcode == CURLM_CALL_MULTI_SOCKET );
    258254
    259255    remove_finished_tasks( g );
    260256
    261     if(( closed = g->closing && !g->taskCount ))
    262         web_close( g );
     257    if( g->closing && !g->taskCount )
     258        web_free( g );
    263259    else
    264260        restart_timer( g );
    265 
    266     return closed;
    267261}
    268262
     
    276270/* CURLMOPT_SOCKETFUNCTION */
    277271static int
    278 sock_cb( CURL * easy UNUSED, curl_socket_t fd, int action,
     272sock_cb( CURL * e UNUSED, curl_socket_t fd, int action,
    279273         void * vweb, void * vevent )
    280274{
     
    282276    struct tr_web * web = vweb;
    283277    struct event * io_event = vevent;
    284     dbgmsg( "sock_cb: action is %d, fd is %d, io_event is %p",
    285             action, (int)fd, io_event );
     278    dbgmsg( "sock_cb: action %d, fd %d, io_event %p", action, (int)fd, io_event );
    286279
    287280    if( action == CURL_POLL_REMOVE )
     
    334327{
    335328    tr_web * g = vg;
    336     tr_bool closed = FALSE;
    337 
    338     if( timer_msec < 1 ) {
    339         if( timer_msec == 0 ) /* call it immediately */
    340             closed = tr_multi_perform( g, CURL_SOCKET_TIMEOUT );
    341         timer_msec = DEFAULT_TIMER_MSEC;
    342     }
    343 
    344     if( !closed ) {
    345         g->timer_msec = timer_msec;
    346         restart_timer( g );
    347     }
     329
     330    g->timer_msec = timer_msec > 0 ? timer_msec : DEFAULT_TIMER_MSEC;
     331
     332    if( timer_msec < 1 )
     333        tr_multi_perform( g, CURL_SOCKET_TIMEOUT );
    348334}
    349335
     
    370356        task->tag = ++tag;
    371357        task->response = evbuffer_new( );
    372 
    373358        tr_runInEventThread( session, addTask, task );
    374359    }
     
    412397    *web_in = NULL;
    413398    if( web->taskCount < 1 )
    414         web_close( web );
     399        web_free( web );
    415400    else
    416401        web->closing = 1;
     
    473458
    474459void
    475 tr_http_escape( struct evbuffer  * out, const char * str, int len, tr_bool escape_slashes )
     460tr_http_escape( struct evbuffer  * out,
     461                const char * str, int len, tr_bool escape_slashes )
    476462{
    477463    int i;
Note: See TracChangeset for help on using the changeset viewer.