From ed51dd9bcc6f0adeb7067aea7c3129eee6017b80 Mon Sep 17 00:00:00 2001 From: Ulrich Hornung Date: Sat, 14 Sep 2024 22:40:10 +0200 Subject: [PATCH] fix issue with survival of nebula service from previous testrun --- udp/udp_linux.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/udp/udp_linux.go b/udp/udp_linux.go index 2eee76ee2..df237f330 100644 --- a/udp/udp_linux.go +++ b/udp/udp_linux.go @@ -22,10 +22,11 @@ import ( //TODO: make it support reload as best you can! type StdConn struct { - sysFd int - isV4 bool - l *logrus.Logger - batch int + sysFd int + closed bool + isV4 bool + l *logrus.Logger + batch int } func maybeIPV4(ip net.IP) (net.IP, bool) { @@ -142,6 +143,11 @@ func (u *StdConn) ListenOut(r EncReader, lhf LightHouseHandlerFunc, cache *firew return } + if u.closed { + u.l.WithError(err).Debug("flag for closing connection is set, exiting read loop") + return + } + //metric.Update(int64(n)) for i := 0; i < n; i++ { if u.isV4 { @@ -315,6 +321,10 @@ func (u *StdConn) getMemInfo(meminfo *[unix.SK_MEMINFO_VARS]uint32) error { func (u *StdConn) Close() error { //TODO: this will not interrupt the read loop + if u.closed { + return nil + } + u.closed = true return syscall.Close(u.sysFd) }