Merge pull request #380 from majestrate/staging

Staging
pull/382/head
Jeff 5 years ago committed by GitHub
commit cf9d6a1793
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -374,13 +374,22 @@ llarp_kqueue_loop::tick(int ms)
llarp::ev_io* ev = static_cast< llarp::ev_io* >(events[idx].udata); llarp::ev_io* ev = static_cast< llarp::ev_io* >(events[idx].udata);
if(ev) if(ev)
{ {
if(events[idx].filter & EVFILT_WRITE) if(events[idx].filter & EV_ERROR)
{ {
ev->flush_write_buffers(events[idx].data); ev->error();
}
else if(events[idx.filter] & EV_EOF == 0)
{
if(events[idx].filter & EVFILT_WRITE)
{
ev->flush_write_buffers(events[idx].data);
}
if(events[idx].filter & EVFILT_READ)
{
ev->read(readbuf,
std::min(sizeof(readbuf), size_t(events[idx].data)));
}
} }
if(events[idx].filter & EVFILT_READ)
ev->read(readbuf,
std::min(sizeof(readbuf), size_t(events[idx].data)));
} }
++idx; ++idx;
} }

@ -46,24 +46,24 @@ namespace llarp
} }
void void
RouterProfile::Clear() RouterProfile::Decay()
{ {
connectGoodCount = 0; connectGoodCount /= 2;
connectTimeoutCount = 0; connectTimeoutCount /= 2;
pathSuccessCount = 0; pathSuccessCount /= 2;
pathFailCount = 0; pathFailCount /= 2;
lastUpdated = llarp::time_now_ms(); lastUpdated = llarp::time_now_ms();
} }
void void
RouterProfile::Tick() RouterProfile::Tick()
{ {
// 10 minutes // 20 minutes
static constexpr llarp_time_t updateInterval = DEFAULT_PATH_LIFETIME; static constexpr llarp_time_t updateInterval = DEFAULT_PATH_LIFETIME * 2;
auto now = llarp::time_now_ms(); auto now = llarp::time_now_ms();
if(lastUpdated < now && now - lastUpdated > updateInterval) if(lastUpdated < now && now - lastUpdated > updateInterval)
{ {
Clear(); Decay();
} }
} }

@ -33,9 +33,9 @@ namespace llarp
bool bool
IsGood(uint64_t chances) const; IsGood(uint64_t chances) const;
/// clear stats /// decay stats
void void
Clear(); Decay();
// rotate stats if timeout reached // rotate stats if timeout reached
void void

Loading…
Cancel
Save