Changeset 3121


Ignore:
Timestamp:
Sep 21, 2007, 2:20:55 PM (15 years ago)
Author:
charles
Message:

fix recursive crash when stopping a torrent, reported by plantain. silence a few more console messages.

Location:
trunk/libtransmission
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/internal.h

    r3119 r3121  
    116116    int                        error;
    117117    char                       errorString[128];
    118     int                        hasChangedState;
    119118
    120119    uint8_t                    obfuscatedHash[SHA_DIGEST_LENGTH];
     
    137136    struct tr_completion     * completion;
    138137
    139     volatile char              dieFlag;
    140138    struct tr_bitfield       * uncheckedPieces;
    141139    run_status_t               runStatus;
    142140    run_status_t               runStatusToSave;
    143     char                       runStatusToSaveIsSet;
    144141    cp_status_t                cpStatus;
    145142    struct tr_lock           * lock;
     
    147144    struct tr_tracker        * tracker;
    148145    struct tr_publisher_tag  * trackerSubscription;
    149     uint64_t                   startDate;
    150     uint64_t                   stopDate;
    151146
    152147    uint64_t                   downloadedCur;
     
    156151    uint64_t                   corruptCur;
    157152    uint64_t                   corruptPrev;
     153
     154    uint64_t                   startDate;
     155    uint64_t                   stopDate;
    158156    uint64_t                   activityDate;
    159157
    160     uint8_t                    pexDisabled;
     158    unsigned int               runStatusToSaveIsSet : 1;
     159    unsigned int               hasChangedState : 1;
     160    unsigned int               pexDisabled : 1;
     161    unsigned int               doStopAfterHashCheck : 1;
     162    unsigned int               statCur : 1;
    161163
    162     int8_t                     statCur;
    163164    tr_stat                    stats[2];
    164165
  • trunk/libtransmission/peer-mgr.c

    r3120 r3121  
    606606    }
    607607
    608     fprintf( stderr, "peer-mgr: torrent [%s] finished a handshake; isConnected is %d\n", t->tor->info.name, isConnected );
     608    fprintf( stderr, "peer-mgr: torrent [%s] finished a handshake. Connected? %s.\n", t->tor->info.name, (isConnected?"yes":"no") );
    609609
    610610    /* if we couldn't connect or were snubbed,
     
    612612    if( !ok ) {
    613613        tr_peer * peer = getExistingPeer( t, in_addr );
    614         fprintf( stderr, "peer-mgr: torrent [%s] got a bad one, and you know what? fuck them.\n", t->tor->info.name );
    615614        tr_peerIoFree( io );
    616615        --manager->connectionCount;
  • trunk/libtransmission/shared.c

    r3119 r3121  
    170170}
    171171
    172 int tr_sharedGetPublicPort( tr_shared * s )
    173 {
    174 fprintf( stderr, "%s:%d tr_sharedGetPublicPort returning %d\n", __FILE__, __LINE__, (int)s->publicPort );
     172int
     173tr_sharedGetPublicPort( const tr_shared * s )
     174{
    175175    return s->publicPort;
    176176}
     
    195195}
    196196
    197 int tr_sharedTraversalStatus( tr_shared * s )
    198 {
    199     int statuses[] = {
     197int tr_sharedTraversalStatus( const tr_shared * s )
     198{
     199    const int statuses[] = {
    200200        TR_NAT_TRAVERSAL_MAPPED,
    201201        TR_NAT_TRAVERSAL_MAPPING,
  • trunk/libtransmission/shared.h

    r3105 r3121  
    5555 **********************************************************************/
    5656void         tr_sharedSetPort         ( tr_shared *, int port );
    57 int          tr_sharedGetPublicPort   ( tr_shared * s );
     57int          tr_sharedGetPublicPort   ( const tr_shared * s );
    5858
    5959/***********************************************************************
     
    6464 **********************************************************************/
    6565void         tr_sharedTraversalEnable ( tr_shared *, int enable );
    66 int          tr_sharedTraversalStatus ( tr_shared * );
     66int          tr_sharedTraversalStatus ( const tr_shared * );
    6767
    6868
  • trunk/libtransmission/torrent.c

    r3119 r3121  
    275275    recheckCpState( tor );
    276276
     277    if( tor->doStopAfterHashCheck ) {
     278        tor->doStopAfterHashCheck = 0;
     279        tr_torrentStop( tor );
     280    }
     281
    277282    if( tor->runStatus == TR_RUN_RUNNING )
    278283        tr_torrentStartImpl( tor );
     
    733738    tr_torrentLock( tor );
    734739
    735     tor->statCur = ( tor->statCur + 1 ) % 2;
     740    tor->statCur = !tor->statCur;
    736741    s = &tor->stats[tor->statCur];
    737742
     
    10601065        case TR_RUN_CHECKING_WAIT:
    10611066        case TR_RUN_CHECKING:
     1067            tor->doStopAfterHashCheck = 1;
    10621068            tr_ioRecheckRemove( tor );
    1063             tr_torrentStop( tor );
    10641069            break;
    10651070
     
    10681073            tr_peerMgrStopTorrent( tor->handle->peerMgr, tor->info.hash );
    10691074            tor->runStatus = TR_RUN_STOPPING;
    1070             tor->stopDate = tr_date( );
    10711075            tr_trackerStop( tor->tracker );
    10721076            tr_ioClose( tor );
     
    10901094    tor->runStatusToSave = tor->runStatus;
    10911095    tor->runStatusToSaveIsSet = TRUE;
    1092     tor->dieFlag = TRUE;
    10931096    tr_torrentStop( tor );
    10941097    tr_timerNew( tor->handle, freeWhenStopped, tor, 250 );
Note: See TracChangeset for help on using the changeset viewer.