do not rely on unspecified Go behaviour; fix TCP ring buffer bug (#16)

* do not rely on unspecified Go behaviour; fix TCP ring buffer bug

* even more stricter error handling on tcp connections

* stricter lock copying in tcp.Conn, even though likely not a problem

* add listener and tcp pool logging

* forgot reqAddr unused

* add logging to TCPConn and friends
This commit is contained in:
Pat Whittingslow
2026-01-05 10:03:24 -03:00
committed by GitHub
parent 018f9258ac
commit 7698b9fb81
14 changed files with 570 additions and 112 deletions
-31
View File
@@ -56,34 +56,3 @@ func SetIPAddrs(buf []byte, id uint16, src, dst []byte) (err error) {
copy(dstaddr, dst)
return nil
}
// IsZeroed returns true if all arguments are set to their zero value.
func IsZeroed[T comparable](a ...T) bool {
var z T
for i := range a {
if a[i] != z {
return false
}
}
return true
}
// DeleteZeroed deletes zero values in-place contained within the
// slice and returns the modified slice without zero values.
// Does not modify capacity.
func DeleteZeroed[T comparable](a []T) []T {
var z T
off := 0
deleted := false
for i := 0; i < len(a); i++ {
if a[i] != z {
if deleted {
a[off] = a[i]
}
off++
} else if !deleted {
deleted = true
}
}
return a[:off]
}