fix crashes

This commit is contained in:
Jeff Becker 2018-12-27 14:10:38 -05:00
parent 4d689da148
commit 6825cc0eec
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
3 changed files with 16 additions and 15 deletions

View File

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

View File

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

View File

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