mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
teminate hadlers upon cleanup
This commit is contained in:
parent
8cb612c10c
commit
309822d933
@ -29,6 +29,14 @@ namespace client
|
|||||||
if (m_LocalDestination) m_LocalDestination->Release ();
|
if (m_LocalDestination) m_LocalDestination->Release ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void I2PService::ClearHandlers ()
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> l(m_HandlersMutex);
|
||||||
|
for (auto it: m_Handlers)
|
||||||
|
it->Terminate ();
|
||||||
|
m_Handlers.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void I2PService::CreateStream (StreamRequestComplete streamRequestComplete, const std::string& dest, int port) {
|
void I2PService::CreateStream (StreamRequestComplete streamRequestComplete, const std::string& dest, int port) {
|
||||||
assert(streamRequestComplete);
|
assert(streamRequestComplete);
|
||||||
i2p::data::IdentHash identHash;
|
i2p::data::IdentHash identHash;
|
||||||
|
@ -31,11 +31,7 @@ namespace client
|
|||||||
std::unique_lock<std::mutex> l(m_HandlersMutex);
|
std::unique_lock<std::mutex> l(m_HandlersMutex);
|
||||||
m_Handlers.erase(conn);
|
m_Handlers.erase(conn);
|
||||||
}
|
}
|
||||||
inline void ClearHandlers ()
|
void ClearHandlers ();
|
||||||
{
|
|
||||||
std::unique_lock<std::mutex> l(m_HandlersMutex);
|
|
||||||
m_Handlers.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::shared_ptr<ClientDestination> GetLocalDestination () { return m_LocalDestination; }
|
inline std::shared_ptr<ClientDestination> GetLocalDestination () { return m_LocalDestination; }
|
||||||
inline std::shared_ptr<const ClientDestination> GetLocalDestination () const { return m_LocalDestination; }
|
inline std::shared_ptr<const ClientDestination> GetLocalDestination () const { return m_LocalDestination; }
|
||||||
@ -66,6 +62,9 @@ namespace client
|
|||||||
virtual ~I2PServiceHandler() { }
|
virtual ~I2PServiceHandler() { }
|
||||||
//If you override this make sure you call it from the children
|
//If you override this make sure you call it from the children
|
||||||
virtual void Handle() {}; //Start handling the socket
|
virtual void Handle() {}; //Start handling the socket
|
||||||
|
|
||||||
|
void Terminate () { Kill (); };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Call when terminating or handing over to avoid race conditions
|
// Call when terminating or handing over to avoid race conditions
|
||||||
inline bool Kill () { return m_Dead.exchange(true); }
|
inline bool Kill () { return m_Dead.exchange(true); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user