Changeset 2330


Ignore:
Timestamp:
Jul 12, 2007, 8:48:13 PM (15 years ago)
Author:
charles
Message:

first draft of a fix for the tracker communication bug reported by TMT

Location:
trunk/libtransmission
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/internal.h

    r2328 r2330  
    148148typedef enum
    149149{
    150     TR_RUN_CHECKING  = (1<<0), /* checking files' checksums */
    151     TR_RUN_RUNNING   = (1<<1), /* seeding or leeching */
    152     TR_RUN_STOPPING  = (1<<2), /* stopping */
    153     TR_RUN_STOPPED   = (1<<3)  /* stopped */
     150    TR_RUN_CHECKING           = (1<<0), /* checking files' checksums */
     151    TR_RUN_RUNNING            = (1<<1), /* seeding or leeching */
     152    TR_RUN_STOPPING           = (1<<2), /* stopping */
     153    TR_RUN_STOPPING_NET_WAIT  = (1<<3), /* waiting on network -- we're
     154                                           telling tracker we've stopped */
     155    TR_RUN_STOPPED            = (1<<4)  /* stopped */
    154156}
    155157run_status_t;
  • trunk/libtransmission/ipcparse.c

    r2328 r2330  
    224224static int          infcmp     ( struct inf *, struct inf * );
    225225static struct msg * msglookup  ( const char * );
    226 static int          filltracker( benc_val_t *, tr_tracker_info_t * );
     226static int          filltracker( benc_val_t *, const tr_tracker_info_t * );
    227227static int          handlercmp ( struct msgfunc *, struct msgfunc * );
    228228
     
    977977}
    978978
    979 int
     979static int
    980980handlevers( struct ipc_info * info, benc_val_t * dict )
    981981{
     
    10371037}
    10381038
    1039 int
     1039static int
    10401040handlemsgs( struct ipc_info * info, benc_val_t * pay, void * arg )
    10411041{
     
    10841084}
    10851085
    1086 int
     1086static int
    10871087gotmsg( struct ipc_info * info, benc_val_t * name, benc_val_t * val,
    10881088        benc_val_t * tagval, void * arg )
     
    12701270}
    12711271
    1272 int
     1272static int
    12731273msgcmp( struct msg * first, struct msg * second )
    12741274{
     
    12761276}
    12771277
    1278 int
     1278static int
    12791279infcmp( struct inf * first, struct inf * second )
    12801280{
     
    12821282}
    12831283
    1284 struct msg *
     1284static struct msg *
    12851285msglookup( const char * name )
    12861286{
     
    13061306}
    13071307
    1308 int
    1309 filltracker( benc_val_t * val, tr_tracker_info_t * tk )
     1308static int
     1309filltracker( benc_val_t * val, const tr_tracker_info_t * tk )
    13101310{
    13111311    tr_bencInit( val, TYPE_DICT );
  • trunk/libtransmission/torrent.c

    r2324 r2330  
    568568        s->status = TR_STATUS_CHECK_WAIT;
    569569    else switch( tor->runStatus ) {
    570         case TR_RUN_STOPPING: s->status = TR_STATUS_STOPPING; break;
     570        case TR_RUN_STOPPING: /* fallthrough */
     571        case TR_RUN_STOPPING_NET_WAIT: s->status = TR_STATUS_STOPPING; break;
    571572        case TR_RUN_STOPPED: s->status = TR_STATUS_STOPPED; break;
    572573        case TR_RUN_CHECKING: s->status = TR_STATUS_CHECK; break;
     
    973974            tor->io = NULL;
    974975
    975             /* close the tracker */
    976             tr_trackerStopped( tor->tracker );
    977             tr_trackerPulse( tor->tracker, &peerCount, &peerCompact );
    978             tr_trackerClose( tor->tracker );
    979             tor->tracker = NULL;
    980 
    981976            /* close the peers */
    982977            for( i=0; i<tor->peerCount; ++i )
     
    989984            tr_rcReset( tor->swarmspeed );
    990985
     986            /* tell the tracker we're stopping */
     987            tr_trackerStopped( tor->tracker );
     988            tr_trackerPulse( tor->tracker, &peerCount, &peerCompact );
     989            tor->runStatus = TR_RUN_STOPPING_NET_WAIT;
    991990            tor->stopDate = tr_date();
    992             tor->runStatus = TR_RUN_STOPPED;
    993 
    994991            tr_torrentWriterUnlock( tor );
     992        }
     993
     994        if( tor->runStatus == TR_RUN_STOPPING_NET_WAIT )
     995        {
     996            /* have we finished telling the tracker that we're stopping? */
     997            const uint64_t date = tr_trackerLastResponseDate( tor->tracker );
     998            if( date > tor->stopDate )
     999            {
     1000                tr_torrentWriterLock( tor );
     1001                tr_trackerClose( tor->tracker );
     1002                tor->tracker = NULL;
     1003                tor->runStatus = TR_RUN_STOPPED;
     1004                tr_torrentWriterUnlock( tor );
     1005            }
     1006            continue;
    9951007        }
    9961008
  • trunk/libtransmission/tracker.c

    r2329 r2330  
    185185{
    186186    tr_torrent_t * tor = tc->tor;
    187     uint64_t       now;
     187    const uint64_t now = tr_date();
    188188   
    189189    /* Last tracker failed, try next */
     
    193193        return 1;
    194194    }
    195    
    196     now = tr_date();
    197195   
    198196    /* If last attempt was an error and it did not change trackers,
     
    839837    if( tc->stopped )
    840838    {
    841         tr_torrentStop( tor );
    842839        tc->stopped = 0;
    843840    }
     
    990987}
    991988
    992 tr_tracker_info_t * tr_trackerGet( tr_tracker_t * tc )
    993 {
    994     if( !tc )
    995     {
    996         return NULL;
    997     }
    998     return tc->tcCur->tl_inf;
     989const tr_tracker_info_t * tr_trackerGet( const tr_tracker_t * tc )
     990{
     991    return tc ? tc->tcCur->tl_inf : NULL;
    999992}
    1000993
     
    1003996    return tc && tc->completelyUnconnectable;
    1004997}
     998
     999uint64_t tr_trackerLastResponseDate ( const tr_tracker_t * tc )
     1000{
     1001    return tc ? tc->dateOk : 0;
     1002}
     1003
    10051004
    10061005/* Blocking version */
  • trunk/libtransmission/tracker.h

    r2329 r2330  
    6565 * Return the tracker currently in use.
    6666 **********************************************************************/
    67 tr_tracker_info_t * tr_trackerGet( tr_tracker_t * tc );
     67const tr_tracker_info_t * tr_trackerGet( const tr_tracker_t * tc );
    6868
    6969int tr_trackerCannotConnect( const tr_tracker_t * tc );
     70
     71/* the time of the tracker's last message to us */
     72uint64_t tr_trackerLastResponseDate ( const tr_tracker_t * );
     73
    7074
    7175/***********************************************************************
  • trunk/libtransmission/transmission.h

    r2319 r2330  
    569569    int                 cannotConnect;
    570570
    571     tr_tracker_info_t * tracker;
     571    const tr_tracker_info_t * tracker;
    572572
    573573    float               percentComplete;
Note: See TracChangeset for help on using the changeset viewer.