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);
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;
}

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

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

Loading…
Cancel
Save