Skip to content

Commit c01468a

Browse files
committed
Drop boost threads for torcontrol
1 parent 27bc007 commit c01468a

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

src/init.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ void PrepareShutdown()
234234
peerLogic.reset();
235235
g_connman.reset();
236236

237+
StopTorControl();
238+
237239
DumpMasternodes();
238240
DumpBudgets(g_budgetman);
239241
DumpMasternodePayments();
@@ -315,8 +317,6 @@ void Shutdown()
315317
if (!fRestartRequested) {
316318
PrepareShutdown();
317319
}
318-
// Shutdown part 2: Stop TOR thread and delete wallet instance
319-
StopTorControl();
320320
#ifdef ENABLE_WALLET
321321
delete pwalletMain;
322322
pwalletMain = NULL;
@@ -1865,7 +1865,7 @@ bool AppInit2()
18651865
#endif
18661866

18671867
if (gArgs.GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION))
1868-
StartTorControl(threadGroup);
1868+
StartTorControl();
18691869

18701870
Discover(threadGroup);
18711871

src/torcontrol.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ void TorController::reconnect_cb(evutil_socket_t fd, short what, void *arg)
733733

734734
/****** Thread ********/
735735
static struct event_base *gBase;
736-
static boost::thread torControlThread;
736+
static std::thread torControlThread;
737737

738738
static void TorControlThread()
739739
{
@@ -742,7 +742,7 @@ static void TorControlThread()
742742
event_base_dispatch(gBase);
743743
}
744744

745-
void StartTorControl(boost::thread_group& threadGroup/*, CScheduler& scheduler*/)
745+
void StartTorControl()
746746
{
747747
assert(!gBase);
748748
#ifdef WIN32
@@ -756,7 +756,7 @@ void StartTorControl(boost::thread_group& threadGroup/*, CScheduler& scheduler*/
756756
return;
757757
}
758758

759-
torControlThread = boost::thread(boost::bind(&TraceThread<void (*)()>, "torcontrol", &TorControlThread));
759+
torControlThread = std::thread(std::bind(&TraceThread<void (*)()>, "torcontrol", &TorControlThread));
760760
}
761761

762762
void InterruptTorControl()
@@ -769,11 +769,9 @@ void InterruptTorControl()
769769

770770
void StopTorControl()
771771
{
772-
// try_join_for() avoids the wallet not closing during a repair-restart. For a 'normal' wallet exit
773-
// it behaves for our cases exactly like the normal join()
774772
if (gBase) {
775-
torControlThread.try_join_for(boost::chrono::seconds(1));
773+
torControlThread.join();
776774
event_base_free(gBase);
777-
gBase = 0;
775+
gBase = nullptr;
778776
}
779777
}

src/torcontrol.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@
1111

1212
#include <string>
1313

14-
#include <boost/chrono/chrono.hpp>
15-
#include <boost/thread.hpp>
16-
1714
extern const std::string DEFAULT_TOR_CONTROL;
1815
static const bool DEFAULT_LISTEN_ONION = true;
1916

20-
void StartTorControl(boost::thread_group& threadGroup);
17+
void StartTorControl();
2118
void InterruptTorControl();
2219
void StopTorControl();
2320

0 commit comments

Comments
 (0)