Reset the peering handler's dropped_paths figure after each log line (closes #116)
check / check (push) Canceled after 0s

processPeerings replaced the path map every run but kept the count of
paths dropped while the map was full, so every later "Processed AS
peerings" line reported all drops since start next to that run's own
figures. The count is now set to 0 where the map is replaced, under the
same lock. A test fills the map, has one path dropped, runs the
processing and finds the count back at 0.

Model: opus-5-5
This commit was merged in pull request #140.
This commit is contained in:
2026-10-20 03:28:06 +02:00
parent 467c295f94
commit bae5a14d76
2 changed files with 34 additions and 2 deletions
+4 -2
View File
@@ -46,7 +46,7 @@ type PeeringHandler struct {
// and the latest time an update carried it.
mu sync.Mutex
asPaths map[string]database.SeenTimes
droppedPaths int // paths dropped because the map was full
droppedPaths int // paths dropped since the last run because the map was full
// writing is how many paths processPeerings took from asPaths and has
// not finished writing the peerings of.
writing int
@@ -190,12 +190,14 @@ func (h *PeeringHandler) processLoop() {
func (h *PeeringHandler) processPeerings() {
// Take the accumulated paths and replace the map with a fresh empty one
// under the lock. Each path is processed exactly once and the memory is
// released, so the map never grows past a single interval's traffic.
// released, so the map never grows past a single interval's traffic. The
// count of dropped paths starts again with the new map.
h.mu.Lock()
paths := h.asPaths
h.asPaths = make(map[string]database.SeenTimes)
h.writing = len(paths)
dropped := h.droppedPaths
h.droppedPaths = 0
h.mu.Unlock()
if len(paths) == 0 {