Changeset 2423


Ignore:
Timestamp:
Jul 19, 2007, 3:48:27 AM (15 years ago)
Author:
charles
Message:

add extra state change checks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r2388 r2423  
    983983
    984984static void
     985recheckCpState( tr_torrent_t * tor )
     986{
     987    cp_status_t cpStatus;
     988
     989    tr_torrentWriterLock( tor );
     990
     991    cpStatus = tr_cpGetStatus( tor->completion );
     992    if( cpStatus != tor->cpStatus ) {
     993        tor->cpStatus = cpStatus;
     994        tor->hasChangedState = tor->cpStatus;  /* tell the client... */
     995        if( (cpStatus == TR_CP_COMPLETE) /* ...and if we're complete */
     996            && tor->tracker!=NULL           /* and we have a tracker */
     997            && tor->downloadedCur ) {        /* and it just happened */
     998            tr_trackerCompleted( tor->tracker ); /* tell the tracker */
     999        }
     1000        tr_ioSync( tor->io );
     1001    }
     1002    tr_torrentWriterUnlock( tor );
     1003}
     1004
     1005static void
    9851006torrentThreadLoop ( void * _tor )
    9861007{
     
    9981019    while( ! ( tor->dieFlag && (tor->runStatus == TR_RUN_STOPPED) ) )
    9991020    {
    1000         cp_status_t cpStatus;
    1001 
    10021021        /* sleep a little while */
    10031022        tr_wait( tor->runStatus == TR_RUN_STOPPED ? 1600 : 600 );
    10041023
    1005         if( tor->fastResumeDirty ) {
     1024        if( tor->fastResumeDirty )
     1025        {
    10061026            tor->fastResumeDirty = FALSE;
    10071027            fastResumeSave( tor );
     1028            recheckCpState( tor );
    10081029        }
    10091030
     
    11091130
    11101131            /* refresh our completion state */
    1111             tr_torrentWriterLock( tor );
    1112             cpStatus = tr_cpGetStatus( tor->completion );
    1113             if( cpStatus != tor->cpStatus ) {
    1114                 tor->cpStatus = cpStatus;
    1115                 tor->hasChangedState = tor->cpStatus;  /* tell the client... */
    1116                 if( (cpStatus == TR_CP_COMPLETE) /* ...and if we're complete */
    1117                     && tor->tracker!=NULL           /* and we have a tracker */
    1118                     && tor->downloadedCur ) {        /* and it just happened */
    1119                     tr_trackerCompleted( tor->tracker ); /* tell the tracker */
    1120                 }
    1121                 tr_ioSync( tor->io );
    1122             }
    1123             tr_torrentWriterUnlock( tor );
     1132            recheckCpState( tor );
    11241133
    11251134            /* ping the tracker... */
Note: See TracChangeset for help on using the changeset viewer.