Count link and syscall failures instead of printing them

This commit is contained in:
flamingcow
2026-07-25 22:54:04 -07:00
parent 1b322bb32b
commit 0f16edfe61
5 changed files with 68 additions and 142 deletions
+5 -17
View File
@@ -1,7 +1,6 @@
package main
import (
"fmt"
"hash/crc32"
"sync"
"sync/atomic"
@@ -15,7 +14,8 @@ type rxStats struct {
badMagic atomic.Uint64
badLen atomic.Uint64
crcErr atomic.Uint64
_ [24]byte
rxErrs atomic.Uint64
_ [16]byte
}
type rxWorker struct {
@@ -24,7 +24,6 @@ type rxWorker struct {
spec *frameSpec
stats *rxStats
streams []lossWindow
reports chan string
ready *sync.WaitGroup
}
@@ -44,7 +43,7 @@ func (w *rxWorker) run(done *atomic.Bool) {
n, err := recvmmsg(w.fd, hdrs, unix.MSG_WAITFORONE)
if n <= 0 {
if err != nil && err != unix.EAGAIN && err != unix.EINTR {
w.report(fmt.Sprintf("recvmmsg: %v", err))
w.stats.rxErrs.Add(1)
}
continue
}
@@ -67,20 +66,9 @@ func (w *rxWorker) run(done *atomic.Bool) {
continue
}
pay := buf[minFrame : minFrame+p.payLen]
if crc32.Checksum(pay, crcTable) == p.crc {
continue
if crc32.Checksum(pay, crcTable) != p.crc {
w.stats.crcErr.Add(1)
}
w.stats.crcErr.Add(1)
off, bits := firstDiff(pay, w.spec.ref[:p.payLen])
w.report(fmt.Sprintf("payload mismatch stream=%d seq=%d len=%d first-diff-offset=%d bits=%d",
p.stream, p.seq, p.payLen, off, bits))
}
}
}
func (w *rxWorker) report(msg string) {
select {
case w.reports <- msg:
default:
}
}