mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
single receive thread for both ipv4 and ipv6
This commit is contained in:
parent
5891b1ceb2
commit
3052dbd1e8
@ -1109,8 +1109,8 @@ namespace transport
|
||||
}
|
||||
|
||||
SSU2Server::SSU2Server ():
|
||||
RunnableServiceWithWork ("SSU2"), m_ReceiveServiceV4 ("SSU2v4"), m_ReceiveServiceV6 ("SSU2v6"),
|
||||
m_SocketV4 (m_ReceiveServiceV4.GetService ()), m_SocketV6 (m_ReceiveServiceV6.GetService ()),
|
||||
RunnableServiceWithWork ("SSU2"), m_ReceiveService ("SSU2r"),
|
||||
m_SocketV4 (m_ReceiveService.GetService ()), m_SocketV6 (m_ReceiveService.GetService ()),
|
||||
m_TerminationTimer (GetService ()), m_ResendTimer (GetService ())
|
||||
{
|
||||
}
|
||||
@ -1120,6 +1120,7 @@ namespace transport
|
||||
if (!IsRunning ())
|
||||
{
|
||||
StartIOService ();
|
||||
bool found = false;
|
||||
auto& addresses = i2p::context.GetRouterInfo ().GetAddresses ();
|
||||
for (const auto& address: addresses)
|
||||
{
|
||||
@ -1141,9 +1142,9 @@ namespace transport
|
||||
{
|
||||
if (address->IsV4 ())
|
||||
{
|
||||
m_ReceiveServiceV4.Start ();
|
||||
found = true;
|
||||
OpenSocket (boost::asio::ip::udp::endpoint (boost::asio::ip::udp::v4(), port));
|
||||
m_ReceiveServiceV4.GetService ().post(
|
||||
m_ReceiveService.GetService ().post(
|
||||
[this]()
|
||||
{
|
||||
Receive (m_SocketV4);
|
||||
@ -1151,9 +1152,9 @@ namespace transport
|
||||
}
|
||||
if (address->IsV6 ())
|
||||
{
|
||||
m_ReceiveServiceV6.Start ();
|
||||
found = true;
|
||||
OpenSocket (boost::asio::ip::udp::endpoint (boost::asio::ip::udp::v6(), port));
|
||||
m_ReceiveServiceV6.GetService ().post(
|
||||
m_ReceiveService.GetService ().post(
|
||||
[this]()
|
||||
{
|
||||
Receive (m_SocketV6);
|
||||
@ -1164,17 +1165,16 @@ namespace transport
|
||||
LogPrint (eLogError, "SSU2: Can't start server because port not specified");
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
m_ReceiveService.Start ();
|
||||
ScheduleTermination ();
|
||||
}
|
||||
}
|
||||
|
||||
void SSU2Server::Stop ()
|
||||
{
|
||||
if (context.SupportsV4 ())
|
||||
m_ReceiveServiceV4.Stop ();
|
||||
|
||||
if (context.SupportsV6 ())
|
||||
m_ReceiveServiceV6.Stop ();
|
||||
if (context.SupportsV4 () || context.SupportsV6 ())
|
||||
m_ReceiveService.Stop ();
|
||||
|
||||
if (IsRunning ())
|
||||
m_TerminationTimer.cancel ();
|
||||
|
@ -262,7 +262,7 @@ namespace transport
|
||||
|
||||
private:
|
||||
|
||||
ReceiveService m_ReceiveServiceV4, m_ReceiveServiceV6;
|
||||
ReceiveService m_ReceiveService;
|
||||
boost::asio::ip::udp::socket m_SocketV4, m_SocketV6;
|
||||
std::unordered_map<uint64_t, std::shared_ptr<SSU2Session> > m_Sessions;
|
||||
std::map<boost::asio::ip::udp::endpoint, std::shared_ptr<SSU2Session> > m_PendingOutgoingSessions;
|
||||
|
Loading…
Reference in New Issue
Block a user