Changeset 2885


Ignore:
Timestamp:
Aug 20, 2007, 11:37:08 PM (15 years ago)
Author:
charles
Message:

better cleanup on shutdown. don't crash when the torrent doesn't support scrape. (Gimp :)

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/tracker.c

    r2876 r2885  
    533533    assert( t->addressIndex >= 0 );
    534534    assert( t->addressIndex < t->addressCount );
     535
    535536    return &t->addresses[t->addressIndex];
    536537}
     538static int
     539trackerSupportsScrape( const Tracker * t )
     540{
     541    const tr_tracker_info_t * info = getCurrentAddress( t );
     542
     543    return ( info != NULL )
     544        && ( info->scrape != NULL )
     545        && ( info->scrape[0] != '\0' );
     546}
     547
    537548
    538549static void
     
    560571{
    561572    Torrent * tor = (Torrent *) vtor;
    562     tr_ptrArrayInsertSorted( tor->tracker->scrapeQueue, tor, torrentCompare );
    563     tr_trackerScrapeSoon( tor->tracker );
     573    if( trackerSupportsScrape( tor->tracker ) ) {
     574        tr_ptrArrayInsertSorted( tor->tracker->scrapeQueue, tor, torrentCompare );
     575        tr_trackerScrapeSoon( tor->tracker );
     576    }
    564577    tor->scrapeTag = NULL;
    565578    return FALSE;
     
    679692{
    680693    Tracker * t = (Tracker*) vt;
     694    const tr_tracker_info_t * address = getCurrentAddress( t );
    681695
    682696    assert( tr_ptrArrayEmpty( t->scraping ) );
    683697
    684     if( !tr_ptrArrayEmpty( t->scrapeQueue ) )
     698    if( trackerSupportsScrape( t ) && !tr_ptrArrayEmpty( t->scrapeQueue ) )
    685699    {
    686700        int i, n, len, addr_len, ask_n;
     
    690704        struct evhttp_connection *evcon = NULL;
    691705        struct evhttp_request *req = NULL;
    692         const tr_tracker_info_t * address = getCurrentAddress( t );
    693706
    694707        ask_n = n;
  • trunk/libtransmission/trevent.c

    r2876 r2885  
    1313#include <assert.h>
    1414#include <errno.h>
    15 #include <stdio.h>
    1615#include <stdlib.h>
    1716#include <string.h>
     
    3635/* #define DEBUG */
    3736#ifdef DEBUG
     37#include <stdio.h>
    3838#undef tr_dbg
    3939#define tr_dbg( a, b... ) fprintf(stderr, a "\n", ##b )
     
    4747{
    4848    int fds[2];
    49     int isShuttingDown;
    5049    tr_lock_t * lock;
    5150    tr_handle_t * h;
     51    struct event_base * base;
    5252    struct event pipeEvent;
    5353}
     
    139139    tr_dbg( "Starting libevent thread" );
    140140
    141     event_init( );
     141    eh->base = event_init( );
    142142    event_set_log_callback( logFunc );
    143143
     
    146146    event_add( &eh->pipeEvent, NULL );
    147147
    148     while( !eh->isShuttingDown ) {
    149         event_dispatch( );
    150         tr_wait( 50 ); /* 1/20th of a second */
    151     }
     148    event_dispatch( );
    152149
    153150    event_del( &eh->pipeEvent );
    154151    tr_lockFree( eh->lock );
     152    event_base_free( eh->base );
    155153    tr_free( eh );
    156154
     
    176174    tr_event_handle_t * eh = handle->events;
    177175
    178     eh->isShuttingDown = TRUE;
     176    event_base_loopexit( eh->base, NULL );
    179177}
    180178
Note: See TracChangeset for help on using the changeset viewer.