diff --git a/llarp/ev/ev_kqueue.cpp b/llarp/ev/ev_kqueue.cpp index 3981f9950..e3ff995ca 100644 --- a/llarp/ev/ev_kqueue.cpp +++ b/llarp/ev/ev_kqueue.cpp @@ -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; } diff --git a/llarp/profiling.cpp b/llarp/profiling.cpp index bfc9c7df8..9516c330e 100644 --- a/llarp/profiling.cpp +++ b/llarp/profiling.cpp @@ -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(); } } diff --git a/llarp/profiling.hpp b/llarp/profiling.hpp index 49799456a..e94d12087 100644 --- a/llarp/profiling.hpp +++ b/llarp/profiling.hpp @@ -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