mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-10-23 06:22:30 +00:00
decline new session if previous one with same destination is being terminated
This commit is contained in:
1 parent
be27640ac6
commit
86cbb4b0de
2 files changed
+12
-4
No files matched your search
+11
-4
@@ -1647,9 +1647,16 @@ namespace client
|
||||
{
|
||||
i2p::data::PrivateKeys keys;
|
||||
if (!keys.FromBase64 (destination)) return nullptr;
|
||||
localDestination = m_IsSingleThread ?
|
||||
i2p::client::context.CreateNewLocalDestination (GetIOService (), keys, true, ¶ms) :
|
||||
i2p::client::context.CreateNewLocalDestination (keys, true, ¶ms);
|
||||
localDestination = i2p::client::context.FindLocalDestination (keys.GetPublic ()->GetIdentHash ());
|
||||
if (localDestination && localDestination->GetRefCounter () <= 0)
|
||||
{
|
||||
LogPrint (eLogError, "SAM: Orphaned destination ", keys.GetPublic ()->GetIdentHash ().ToBase32 (), ". Try later");
|
||||
return nullptr;
|
||||
}
|
||||
if (!localDestination)
|
||||
localDestination = m_IsSingleThread ?
|
||||
i2p::client::context.CreateNewLocalDestination (GetIOService (), keys, true, ¶ms) :
|
||||
i2p::client::context.CreateNewLocalDestination (keys, true, ¶ms);
|
||||
}
|
||||
else // transient
|
||||
{
|
||||
@@ -1716,7 +1723,7 @@ namespace client
|
||||
void SAMBridge::ScheduleSessionCleanupTimer (std::shared_ptr<SAMSession> session)
|
||||
{
|
||||
auto timer = std::make_shared<boost::asio::steady_timer>(GetService ());
|
||||
timer->expires_after (std::chrono::seconds(5)); // postpone destination clean for 5 seconds
|
||||
timer->expires_after (std::chrono::seconds(SAM_SESSION_CLEANUP_CHECK_INTERVAL)); // postpone destination cleanup
|
||||
timer->async_wait (std::bind (&SAMBridge::HandleSessionCleanupTimer, this, std::placeholders::_1, session, timer));
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace client
|
||||
const size_t SAM_STREAM_MAX_SEND_BUFFER_SIZE = 8*SAM_SOCKET_BUFFER_SIZE;
|
||||
const int SAM_SOCKET_CONNECTION_MAX_IDLE = 3600; // in seconds
|
||||
const int SAM_SESSION_READINESS_CHECK_INTERVAL = 3; // in seconds
|
||||
const int SAM_SESSION_CLEANUP_CHECK_INTERVAL = 5; // in seconds
|
||||
const size_t SAM_SESSION_MAX_ACCEPT_QUEUE_SIZE = 50;
|
||||
const size_t SAM_SESSION_MAX_ACCEPT_INTERVAL = 3; // in seconds
|
||||
|
||||
|
||||
Reference in new issue
Block a user