mirror of https://github.com/oxen-io/lokinet
Merge pull request #1865 from majestrate/proto-fix-2022-03-06
fix wire protocol race condition
This commit is contained in:
commit
27d883157d
|
@ -174,7 +174,10 @@ namespace llarp
|
|||
if (m_State == State::Ready)
|
||||
m_Parent->UnmapAddr(m_RemoteAddr);
|
||||
m_State = State::Closed;
|
||||
if (m_SentClosed.test_and_set())
|
||||
return;
|
||||
EncryptAndSend(std::move(close_msg));
|
||||
|
||||
LogInfo(m_Parent->PrintableName(), " closing connection to ", m_RemoteAddr);
|
||||
}
|
||||
|
||||
|
@ -338,7 +341,7 @@ namespace llarp
|
|||
bool
|
||||
Session::TimedOut(llarp_time_t now) const
|
||||
{
|
||||
if (m_State == State::Ready || m_State == State::LinkIntro)
|
||||
if (m_State == State::Ready)
|
||||
{
|
||||
return now > m_LastRX
|
||||
&& now - m_LastRX
|
||||
|
|
|
@ -203,6 +203,7 @@ namespace llarp
|
|||
|
||||
std::atomic_flag m_PlaintextEmpty;
|
||||
llarp::thread::Queue<CryptoQueue_t> m_PlaintextRecv;
|
||||
std::atomic_flag m_SentClosed;
|
||||
|
||||
void
|
||||
EncryptWorker(CryptoQueue_t msgs);
|
||||
|
|
|
@ -443,6 +443,8 @@ namespace llarp
|
|||
LogError("RC is invalid, not saving");
|
||||
return false;
|
||||
}
|
||||
if (m_isServiceNode)
|
||||
_nodedb->Put(_rc);
|
||||
QueueDiskIO([&]() { HandleSaveRC(); });
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue