Changeset 12506


Ignore:
Timestamp:
Jun 19, 2011, 6:18:48 PM (10 years ago)
Author:
jordan
Message:

(trunk libT) don't use tr_list for the tr_web_task queue

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/web.c

    r12461 r12506  
    2525
    2626#include "transmission.h"
    27 #include "list.h"
    2827#include "net.h" /* tr_address */
    2928#include "platform.h" /* mutex */
     
    6160***/
    6261
    63 struct tr_web
    64 {
    65     bool curl_verbose;
    66     int close_mode;
    67     tr_list * tasks;
    68     tr_lock * taskLock;
    69     char * cookie_filename;
    70 };
    71 
    72 
    73 /***
    74 ****
    75 ***/
    76 
    7762struct tr_web_task
    7863{
     
    8974    tr_web_done_func * done_func;
    9075    void * done_func_user_data;
     76    struct tr_web_task * next;
    9177};
    9278
     
    10187    tr_free( task );
    10288}
     89
     90/***
     91****
     92***/
     93
     94struct tr_web
     95{
     96    bool curl_verbose;
     97    int close_mode;
     98    struct tr_web_task * tasks;
     99    tr_lock * taskLock;
     100    char * cookie_filename;
     101};
    103102
    104103/***
     
    259258
    260259        tr_lockLock( web->taskLock );
    261         tr_list_append( &web->tasks, task );
     260        task->next = web->tasks;
     261        web->tasks = task;
    262262        tr_lockUnlock( web->taskLock );
    263263    }
     
    335335        /* add tasks from the queue */
    336336        tr_lockLock( web->taskLock );
    337         while(( task = tr_list_pop_front( &web->tasks )))
     337        while( web->tasks != NULL )
    338338        {
     339            /* pop the task */
     340            task = web->tasks;
     341            web->tasks = task->next;
     342            task->next = NULL;
     343
    339344            dbgmsg( "adding task to curl: [%s]", task->url );
    340345            curl_multi_add_handle( multi, createEasy( session, web, task ));
     
    400405            }
    401406        }
    402 
    403 #if 0
    404 {
    405 tr_list * l;
    406 for( l=web->tasks; l!=NULL; l=l->next )
    407     fprintf( stderr, "still pending: %s\n", ((struct tr_web_task*)l->data)->url );
    408 }
    409 fprintf( stderr, "loop is ending... web is closing\n" );
    410 #endif
    411407    }
    412408
    413409    /* Discard any remaining tasks.
    414410     * This is rare, but can happen on shutdown with unresponsive trackers. */
    415     while(( task = tr_list_pop_front( &web->tasks ))) {
     411    while( web->tasks != NULL ) {
     412        task = web->tasks;
     413        web->tasks = task->next;
    416414        dbgmsg( "Discarding task \"%s\"", task->url );
    417415        task_free( task );
Note: See TracChangeset for help on using the changeset viewer.