fix recursive crash when stopping a torrent, reported by plantain. silence a few more console messages.
This commit is contained in:
parent
54c84d0b30
commit
9248143ce8
|
@ -115,7 +115,6 @@ struct tr_torrent
|
||||||
|
|
||||||
int error;
|
int error;
|
||||||
char errorString[128];
|
char errorString[128];
|
||||||
int hasChangedState;
|
|
||||||
|
|
||||||
uint8_t obfuscatedHash[SHA_DIGEST_LENGTH];
|
uint8_t obfuscatedHash[SHA_DIGEST_LENGTH];
|
||||||
|
|
||||||
|
@ -136,18 +135,14 @@ struct tr_torrent
|
||||||
|
|
||||||
struct tr_completion * completion;
|
struct tr_completion * completion;
|
||||||
|
|
||||||
volatile char dieFlag;
|
|
||||||
struct tr_bitfield * uncheckedPieces;
|
struct tr_bitfield * uncheckedPieces;
|
||||||
run_status_t runStatus;
|
run_status_t runStatus;
|
||||||
run_status_t runStatusToSave;
|
run_status_t runStatusToSave;
|
||||||
char runStatusToSaveIsSet;
|
|
||||||
cp_status_t cpStatus;
|
cp_status_t cpStatus;
|
||||||
struct tr_lock * lock;
|
struct tr_lock * lock;
|
||||||
|
|
||||||
struct tr_tracker * tracker;
|
struct tr_tracker * tracker;
|
||||||
struct tr_publisher_tag * trackerSubscription;
|
struct tr_publisher_tag * trackerSubscription;
|
||||||
uint64_t startDate;
|
|
||||||
uint64_t stopDate;
|
|
||||||
|
|
||||||
uint64_t downloadedCur;
|
uint64_t downloadedCur;
|
||||||
uint64_t downloadedPrev;
|
uint64_t downloadedPrev;
|
||||||
|
@ -155,11 +150,17 @@ struct tr_torrent
|
||||||
uint64_t uploadedPrev;
|
uint64_t uploadedPrev;
|
||||||
uint64_t corruptCur;
|
uint64_t corruptCur;
|
||||||
uint64_t corruptPrev;
|
uint64_t corruptPrev;
|
||||||
|
|
||||||
|
uint64_t startDate;
|
||||||
|
uint64_t stopDate;
|
||||||
uint64_t activityDate;
|
uint64_t activityDate;
|
||||||
|
|
||||||
uint8_t pexDisabled;
|
unsigned int runStatusToSaveIsSet : 1;
|
||||||
|
unsigned int hasChangedState : 1;
|
||||||
|
unsigned int pexDisabled : 1;
|
||||||
|
unsigned int doStopAfterHashCheck : 1;
|
||||||
|
unsigned int statCur : 1;
|
||||||
|
|
||||||
int8_t statCur;
|
|
||||||
tr_stat stats[2];
|
tr_stat stats[2];
|
||||||
|
|
||||||
tr_torrent * next;
|
tr_torrent * next;
|
||||||
|
|
|
@ -605,13 +605,12 @@ myHandshakeDoneCB( tr_handshake * handshake,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( stderr, "peer-mgr: torrent [%s] finished a handshake; isConnected is %d\n", t->tor->info.name, isConnected );
|
fprintf( stderr, "peer-mgr: torrent [%s] finished a handshake. Connected? %s.\n", t->tor->info.name, (isConnected?"yes":"no") );
|
||||||
|
|
||||||
/* if we couldn't connect or were snubbed,
|
/* if we couldn't connect or were snubbed,
|
||||||
* the peer's probably not worth remembering. */
|
* the peer's probably not worth remembering. */
|
||||||
if( !ok ) {
|
if( !ok ) {
|
||||||
tr_peer * peer = getExistingPeer( t, in_addr );
|
tr_peer * peer = getExistingPeer( t, in_addr );
|
||||||
fprintf( stderr, "peer-mgr: torrent [%s] got a bad one, and you know what? fuck them.\n", t->tor->info.name );
|
|
||||||
tr_peerIoFree( io );
|
tr_peerIoFree( io );
|
||||||
--manager->connectionCount;
|
--manager->connectionCount;
|
||||||
if( peer ) {
|
if( peer ) {
|
||||||
|
|
|
@ -169,9 +169,9 @@ void tr_sharedSetPort( tr_shared * s, int port )
|
||||||
tr_sharedUnlock( s );
|
tr_sharedUnlock( s );
|
||||||
}
|
}
|
||||||
|
|
||||||
int tr_sharedGetPublicPort( tr_shared * s )
|
int
|
||||||
|
tr_sharedGetPublicPort( const tr_shared * s )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "%s:%d tr_sharedGetPublicPort returning %d\n", __FILE__, __LINE__, (int)s->publicPort );
|
|
||||||
return s->publicPort;
|
return s->publicPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,9 +194,9 @@ void tr_sharedTraversalEnable( tr_shared * s, int enable )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int tr_sharedTraversalStatus( tr_shared * s )
|
int tr_sharedTraversalStatus( const tr_shared * s )
|
||||||
{
|
{
|
||||||
int statuses[] = {
|
const int statuses[] = {
|
||||||
TR_NAT_TRAVERSAL_MAPPED,
|
TR_NAT_TRAVERSAL_MAPPED,
|
||||||
TR_NAT_TRAVERSAL_MAPPING,
|
TR_NAT_TRAVERSAL_MAPPING,
|
||||||
TR_NAT_TRAVERSAL_UNMAPPING,
|
TR_NAT_TRAVERSAL_UNMAPPING,
|
||||||
|
|
|
@ -54,7 +54,7 @@ void tr_sharedUnlock ( tr_shared * );
|
||||||
* should be called with the shared lock held.
|
* should be called with the shared lock held.
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
void tr_sharedSetPort ( tr_shared *, int port );
|
void tr_sharedSetPort ( tr_shared *, int port );
|
||||||
int tr_sharedGetPublicPort ( tr_shared * s );
|
int tr_sharedGetPublicPort ( const tr_shared * s );
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* tr_sharedTraversalEnable, tr_sharedTraversalStatus
|
* tr_sharedTraversalEnable, tr_sharedTraversalStatus
|
||||||
|
@ -63,7 +63,7 @@ int tr_sharedGetPublicPort ( tr_shared * s );
|
||||||
* be called with the shared lock held.
|
* be called with the shared lock held.
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
void tr_sharedTraversalEnable ( tr_shared *, int enable );
|
void tr_sharedTraversalEnable ( tr_shared *, int enable );
|
||||||
int tr_sharedTraversalStatus ( tr_shared * );
|
int tr_sharedTraversalStatus ( const tr_shared * );
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -274,6 +274,11 @@ recheckDoneCB( tr_torrent * tor )
|
||||||
{
|
{
|
||||||
recheckCpState( tor );
|
recheckCpState( tor );
|
||||||
|
|
||||||
|
if( tor->doStopAfterHashCheck ) {
|
||||||
|
tor->doStopAfterHashCheck = 0;
|
||||||
|
tr_torrentStop( tor );
|
||||||
|
}
|
||||||
|
|
||||||
if( tor->runStatus == TR_RUN_RUNNING )
|
if( tor->runStatus == TR_RUN_RUNNING )
|
||||||
tr_torrentStartImpl( tor );
|
tr_torrentStartImpl( tor );
|
||||||
}
|
}
|
||||||
|
@ -732,7 +737,7 @@ tr_torrentStat( tr_torrent * tor )
|
||||||
|
|
||||||
tr_torrentLock( tor );
|
tr_torrentLock( tor );
|
||||||
|
|
||||||
tor->statCur = ( tor->statCur + 1 ) % 2;
|
tor->statCur = !tor->statCur;
|
||||||
s = &tor->stats[tor->statCur];
|
s = &tor->stats[tor->statCur];
|
||||||
|
|
||||||
s->error = tor->error;
|
s->error = tor->error;
|
||||||
|
@ -1059,15 +1064,14 @@ tr_torrentStopImpl( void * vtor )
|
||||||
{
|
{
|
||||||
case TR_RUN_CHECKING_WAIT:
|
case TR_RUN_CHECKING_WAIT:
|
||||||
case TR_RUN_CHECKING:
|
case TR_RUN_CHECKING:
|
||||||
|
tor->doStopAfterHashCheck = 1;
|
||||||
tr_ioRecheckRemove( tor );
|
tr_ioRecheckRemove( tor );
|
||||||
tr_torrentStop( tor );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TR_RUN_RUNNING:
|
case TR_RUN_RUNNING:
|
||||||
saveFastResumeNow( tor );
|
saveFastResumeNow( tor );
|
||||||
tr_peerMgrStopTorrent( tor->handle->peerMgr, tor->info.hash );
|
tr_peerMgrStopTorrent( tor->handle->peerMgr, tor->info.hash );
|
||||||
tor->runStatus = TR_RUN_STOPPING;
|
tor->runStatus = TR_RUN_STOPPING;
|
||||||
tor->stopDate = tr_date( );
|
|
||||||
tr_trackerStop( tor->tracker );
|
tr_trackerStop( tor->tracker );
|
||||||
tr_ioClose( tor );
|
tr_ioClose( tor );
|
||||||
break;
|
break;
|
||||||
|
@ -1089,7 +1093,6 @@ tr_torrentClose( tr_torrent * tor )
|
||||||
{
|
{
|
||||||
tor->runStatusToSave = tor->runStatus;
|
tor->runStatusToSave = tor->runStatus;
|
||||||
tor->runStatusToSaveIsSet = TRUE;
|
tor->runStatusToSaveIsSet = TRUE;
|
||||||
tor->dieFlag = TRUE;
|
|
||||||
tr_torrentStop( tor );
|
tr_torrentStop( tor );
|
||||||
tr_timerNew( tor->handle, freeWhenStopped, tor, 250 );
|
tr_timerNew( tor->handle, freeWhenStopped, tor, 250 );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue