Ignore:
Timestamp:
Apr 10, 2009, 5:34:25 PM (13 years ago)
Author:
charles
Message:

(1.5x libT) various backports for 1.52:
(1) recognize Aria2 as a client
(2) remove jhujhiti's tr_suspectAddress(), since he removed it from trunka
(3) on Mac, better detection of where the Web UI files are located
(4) reintroduce the web task queue
(5) various minor formatting changes to reduce the diffs between 1.52 and trunk

File:
1 edited

Legend:

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

    r7906 r8204  
    7373    tr_session * session;
    7474    struct event timer_event;
     75    tr_list * easy_queue;
    7576    tr_list * fds;
    7677};
     
    215216            curl_easy_setopt( easy, CURLOPT_ENCODING, "" );
    216217
    217         {
     218        if( web->still_running >= MAX_CONCURRENT_TASKS ) {
     219            tr_list_append( &web->easy_queue, easy );
     220            dbgmsg( ">> enqueueing a task... size is now %d", tr_list_size( web->easy_queue ) );
     221        } else {
    218222            const CURLMcode mcode = curl_multi_add_handle( web->multi, easy );
    219223            tr_assert( mcode == CURLM_OK, "curl_multi_add_handle() failed: %d (%s)", mcode, curl_multi_strerror( mcode ) );
     
    323327    tr_timevalMsec( g->timer_ms, &interval );
    324328    evtimer_add( &g->timer_event, &interval );
     329}
     330
     331static void
     332add_tasks_from_queue( tr_web * g )
     333{
     334    while( ( g->still_running < MAX_CONCURRENT_TASKS )
     335        && ( tr_list_size( g->easy_queue ) > 0 ) )
     336    {
     337        CURL * easy = tr_list_pop_front( &g->easy_queue );
     338        if( easy )
     339        {
     340            const CURLMcode rc = curl_multi_add_handle( g->multi, easy );
     341            if( rc != CURLM_OK )
     342                tr_err( "%s", curl_multi_strerror( rc ) );
     343            else {
     344                dbgmsg( "pumped the task queue, %d remain",
     345                        tr_list_size( g->easy_queue ) );
     346                ++g->still_running;
     347            }
     348        }
     349    }
    325350}
    326351
     
    372397
    373398    remove_finished_tasks( g );
     399
     400    add_tasks_from_queue( g );
    374401
    375402    if( !g->still_running ) {
Note: See TracChangeset for help on using the changeset viewer.