fix crashes

pull/189/head
Jeff Becker 6 years ago
parent 4d689da148
commit 6825cc0eec
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -93,7 +93,7 @@ namespace llarp
auto itr = m_AuthedLinks.begin(); auto itr = m_AuthedLinks.begin();
while(itr != m_AuthedLinks.end()) while(itr != m_AuthedLinks.end())
{ {
if(!itr->second->TimedOut(_now)) if(itr->second.get() && !itr->second->TimedOut(_now))
{ {
itr->second->Pump(); itr->second->Pump();
++itr; ++itr;
@ -112,7 +112,7 @@ namespace llarp
auto itr = m_Pending.begin(); auto itr = m_Pending.begin();
while(itr != m_Pending.end()) while(itr != m_Pending.end())
{ {
if(!(*itr)->TimedOut(_now)) if(itr->get() && !(*itr)->TimedOut(_now))
{ {
(*itr)->Pump(); (*itr)->Pump();
++itr; ++itr;
@ -324,7 +324,8 @@ namespace llarp
void void
ILinkLayer::OnTick(uint64_t interval) ILinkLayer::OnTick(uint64_t interval)
{ {
Tick(Now()); auto now = Now();
Tick(now);
ScheduleTick(interval); ScheduleTick(interval);
} }

@ -706,6 +706,9 @@ namespace llarp
llarp::LogDebug("Sent reply LIM"); llarp::LogDebug("Sent reply LIM");
gotLIM = true; gotLIM = true;
EnterState(eSessionReady); EnterState(eSessionReady);
/// future LIM are used for session renegotiation
GotLIM = std::bind(&Session::GotSessionRenegotiate, this,
std::placeholders::_1);
} }
return true; return true;
} }
@ -749,6 +752,8 @@ namespace llarp
return false; return false;
} }
EnterState(eSessionReady); EnterState(eSessionReady);
/// future LIM are used for session renegotiation
GotLIM = std::bind(&Session::GotSessionRenegotiate, this,std::placeholders::_1);
return true; return true;
} }
@ -944,9 +949,6 @@ namespace llarp
{ {
parent->MapAddr(remoteRC.pubkey.data(), this); parent->MapAddr(remoteRC.pubkey.data(), this);
parent->SessionEstablished(remoteRC); parent->SessionEstablished(remoteRC);
/// future LIM are used for session renegotiation
GotLIM = std::bind(&Session::GotSessionRenegotiate, this,
std::placeholders::_1);
} }
} }
@ -1066,17 +1068,17 @@ namespace llarp
llarp::LogError("inbound buffer is full"); llarp::LogError("inbound buffer is full");
return false; // not enough room return false; // not enough room
} }
// determine if this message is done
bool result = true;
// mutate key // mutate key
if(!MutateKey(rxKey, A)) if(!MutateKey(rxKey, A))
{ {
llarp::LogError("failed to mutate rx key"); llarp::LogError("failed to mutate rx key");
return false; return false;
} }
if(remaining == 0) if(remaining == 0)
{ {
// we done with this guy, prune next tick
itr->second.lastActive = 0;
llarp_buffer_t buf = itr->second.buffer; llarp_buffer_t buf = itr->second.buffer;
// resize // resize
buf.sz = buf.cur - buf.base; buf.sz = buf.cur - buf.base;
@ -1084,12 +1086,9 @@ namespace llarp
buf.cur = buf.base; buf.cur = buf.base;
// process buffer // process buffer
llarp::LogDebug("got message ", msgid, " from ", remoteAddr); llarp::LogDebug("got message ", msgid, " from ", remoteAddr);
result = parent->HandleMessage(this, buf); return parent->HandleMessage(this, buf);
// get rid of message buffer
if(result)
m_RecvMsgs.erase(itr->first);
} }
return result; return true;
} }
void void

@ -97,7 +97,8 @@ llarp_threadpool_tick(struct llarp_threadpool *pool)
job = std::move(pool->jobs.front()); job = std::move(pool->jobs.front());
pool->jobs.pop(); pool->jobs.pop();
} }
job(); if(job)
job();
} }
} }

Loading…
Cancel
Save