mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-27 11:17:49 +02:00
add threadpool for ntcp dh
This commit is contained in:
parent
b02464990b
commit
91fdb038d9
3 changed files with 98 additions and 17 deletions
|
@ -171,27 +171,14 @@ namespace transport
|
|||
return;
|
||||
}
|
||||
}
|
||||
#if ((__GNUC__ == 4) && (__GNUC_MINOR__ <= 7)) || defined(__NetBSD__)
|
||||
// due the bug in gcc 4.7. std::shared_future.get() is not const
|
||||
if (!m_DHKeysPair)
|
||||
m_DHKeysPair = transports.GetNextDHKeysPair ();
|
||||
CreateAESKey (m_Establisher->phase1.pubKey);
|
||||
SendPhase2 ();
|
||||
#else
|
||||
// TODO: check for number of pending keys
|
||||
auto s = shared_from_this ();
|
||||
auto keyCreated = std::async (std::launch::async, [s] ()
|
||||
{
|
||||
m_Server.Work(s, [s]() -> std::function<void(void)> {
|
||||
if (!s->m_DHKeysPair)
|
||||
s->m_DHKeysPair = transports.GetNextDHKeysPair ();
|
||||
s->CreateAESKey (s->m_Establisher->phase1.pubKey);
|
||||
}).share ();
|
||||
m_Server.GetService ().post ([s, keyCreated]()
|
||||
{
|
||||
keyCreated.get ();
|
||||
s->SendPhase2 ();
|
||||
return std::bind(&NTCPSession::SendPhase2, s);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -788,12 +775,14 @@ namespace transport
|
|||
}
|
||||
|
||||
//-----------------------------------------
|
||||
NTCPServer::NTCPServer ():
|
||||
NTCPServer::NTCPServer (int workers):
|
||||
m_IsRunning (false), m_Thread (nullptr), m_Work (m_Service),
|
||||
m_TerminationTimer (m_Service), m_NTCPAcceptor (nullptr), m_NTCPV6Acceptor (nullptr),
|
||||
m_ProxyType(eNoProxy), m_Resolver(m_Service), m_ProxyEndpoint(nullptr),
|
||||
m_SoftLimit(0), m_HardLimit(0)
|
||||
{
|
||||
if(workers <= 0) workers = 1;
|
||||
m_CryptoPool = std::make_shared<Pool>(workers);
|
||||
}
|
||||
|
||||
NTCPServer::~NTCPServer ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue