diff --git a/libretroshare/src/retroshare/rstor.h b/libretroshare/src/retroshare/rstor.h index 0ae966a7e..8eaa4a352 100644 --- a/libretroshare/src/retroshare/rstor.h +++ b/libretroshare/src/retroshare/rstor.h @@ -141,6 +141,12 @@ public: */ static bool start(); + /*! + * \brief stop + * Stop the Tor management threads. + */ + static void stop(); + /*! * \brief getHiddenServiceInfo * Gets information about the hidden service setup by RS to run. diff --git a/libretroshare/src/tor/TorManager.cpp b/libretroshare/src/tor/TorManager.cpp index 628f35733..ff2d53ced 100644 --- a/libretroshare/src/tor/TorManager.cpp +++ b/libretroshare/src/tor/TorManager.cpp @@ -53,6 +53,8 @@ using namespace Tor; +static TorManager *rsTor = nullptr; + namespace Tor { @@ -840,6 +842,17 @@ bool RsTor::start() return instance()->startTorManager(); } +void RsTor::stop() +{ + if (rsTor) { + if (rsTor->isRunning()) { + rsTor->fullstop(); + } + delete(rsTor); + rsTor= nullptr; + } +} + void RsTor::setTorDataDirectory(const std::string& dir) { instance()->setTorDataDirectory(dir); @@ -855,8 +868,6 @@ TorManager *RsTor::instance() assert(getpid() == syscall(SYS_gettid));// make sure we're not in a thread #endif - static TorManager *rsTor = nullptr; - if(rsTor == nullptr) rsTor = new TorManager; diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index d8818db0c..82d78d2b2 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -591,6 +591,10 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); RsGxsUpdateBroadcast::cleanup(); #endif + if (is_auto_tor) { + RsTor::stop(); + } + RsControl::instance()->rsGlobalShutDown(); delete(soundManager);