Added timeout to read failure in rdpControlConn to avoid spinning on error.

This commit is contained in:
jdl
2026-06-13 09:07:03 +02:00
parent f3d8a9ff75
commit a730211167
2 changed files with 5 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import (
"log"
"net"
"net/netip"
"time"
"vppn/peer/control"
)
@@ -32,11 +33,14 @@ func (c *udpControlConn) SendPing(dst netip.AddrPort, ping control.Ping, buf []b
// run reads incoming ping packets and forwards them to ch until ctx is done.
// Call this in a goroutine before starting the App event loop.
func (c *udpControlConn) run(ch chan<- PingEvent) {
const errorTimeout = 8 * time.Second
var buf [control.Size]byte
for {
n, src, err := c.conn.ReadFromUDP(buf[:])
if err != nil {
log.Printf("control read: %v", err)
time.Sleep(errorTimeout)
continue
}