From 42cc9a80607e27216f310457cff3fee643f10b61 Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Wed, 3 Jul 2024 20:44:17 +0800 Subject: [PATCH] opt: prevent server-side UDP sockets in eventloop.close() on Windows Follows up #624 --- eventloop_windows.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/eventloop_windows.go b/eventloop_windows.go index 93cadabf3..74bea1a46 100644 --- a/eventloop_windows.go +++ b/eventloop_windows.go @@ -185,7 +185,7 @@ func (el *eventloop) wake(c *conn) error { } func (el *eventloop) close(c *conn, err error) error { - if _, ok := el.connections[c]; c.localAddr == nil || !ok { + if _, ok := el.connections[c]; c.rawConn == nil || !ok { return nil // ignore stale wakes. } @@ -194,9 +194,7 @@ func (el *eventloop) close(c *conn, err error) error { action := el.eventHandler.OnClose(c, err) err = nil - if c.rawConn != nil { - err = c.rawConn.Close() - } + err = c.rawConn.Close() c.release() if err != nil { return err