@@ -462,8 +462,7 @@ void StopTorrentDHTNetwork()
462
462
{
463
463
LogPrintf (" %s --Begin stopping all DHT session threads.\n " , __func__);
464
464
fRun = false ;
465
- if (pDHTTorrentThread != NULL )
466
- {
465
+ if (pDHTTorrentThread != nullptr ) {
467
466
size_t nRunningThreads = fMultiThreads ? nThreads : 1 ;
468
467
LogPrint (" dht" , " DHTTorrentNetwork -- StopTorrentDHTNetwork trying to stop.\n " );
469
468
if (fStarted ) {
@@ -486,21 +485,26 @@ void StopTorrentDHTNetwork()
486
485
pairSession.second ->Session ->apply_settings (params.settings );
487
486
pairSession.second ->Session ->abort ();
488
487
}
489
-
488
+ } else {
489
+ MilliSleep (1001 );
490
490
}
491
+
491
492
pDHTTorrentThread->join ();
492
- // join all DHT threads
493
- if (fMultiThreads ) {
494
- for (unsigned int i = 0 ; i < nThreads; i++) {
495
- std::pair<std::shared_ptr<std::thread>, std::shared_ptr<CHashTableSession>> pairSession = arraySessions[i];
493
+
494
+ if (fStarted ) {
495
+ // join all DHT threads
496
+ if (fMultiThreads ) {
497
+ for (unsigned int i = 0 ; i < nThreads; i++) {
498
+ std::pair<std::shared_ptr<std::thread>, std::shared_ptr<CHashTableSession>> pairSession = arraySessions[i];
499
+ pairSession.first ->join ();
500
+ }
501
+ } else {
502
+ std::pair<std::shared_ptr<std::thread>, std::shared_ptr<CHashTableSession>> pairSession = arraySessions[0 ];
496
503
pairSession.first ->join ();
497
504
}
498
- } else {
499
- std::pair<std::shared_ptr<std::thread>, std::shared_ptr<CHashTableSession>> pairSession = arraySessions[0 ];
500
- pairSession.first ->join ();
501
505
}
502
506
}
503
-
507
+
504
508
if (fReannounceStarted ) {
505
509
// Stop ReannounceEntries
506
510
fReannounceStarted = false ;
0 commit comments