pump only on send queue full and clear exit roles when closing exit

pull/598/head
Jeff Becker 5 years ago
parent b68f539de6
commit 9d466cd09d
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -155,13 +155,18 @@ namespace llarp
BaseSession::ResetInternalState()
{
auto sendExitClose = [&](const llarp::path::Path_ptr p) {
if(p->SupportsAnyRoles(llarp::path::ePathRoleExit
| llarp::path::ePathRoleSVC))
const static auto roles =
llarp::path::ePathRoleExit | llarp::path::ePathRoleSVC;
if(p->SupportsAnyRoles(roles))
{
llarp::LogInfo(p->Name(), " closing exit path");
llarp::routing::CloseExitMessage msg;
if(!(msg.Sign(router->crypto(), m_ExitIdentity)
&& p->SendExitClose(msg, router)))
if(msg.Sign(router->crypto(), m_ExitIdentity)
&& p->SendExitClose(msg, router))
{
p->ClearRoles(roles);
}
else
llarp::LogWarn(p->Name(), " failed to send exit close message");
}
};

@ -385,6 +385,13 @@ namespace llarp
return roles == ePathRoleAny || (_role | roles) != 0;
}
/// clear role bits
void
ClearRoles(PathRole roles)
{
_role &= ~roles;
}
PathStatus
Status() const
{

@ -254,7 +254,16 @@ namespace llarp
Session::SendMessageBuffer(const llarp_buffer_t& buf)
{
if(sendq.size() >= MaxSendQueueSize)
{
// pump write queue if we seem to be full
PumpWrite();
}
if(sendq.size() >= MaxSendQueueSize)
{
// we didn't pump anything wtf
// this means we're stalled
return false;
}
size_t sz = buf.sz;
byte_t* ptr = buf.base;
uint32_t msgid = m_NextTXMsgID++;
@ -270,7 +279,6 @@ namespace llarp
ptr += s;
sz -= s;
}
PumpWrite();
return true;
}

Loading…
Cancel
Save