tsnet: return from Accept when the listener gets closed

Fixes #14808

Signed-off-by: Anton Tolchanov <anton@tailscale.com>
This commit is contained in:
Anton Tolchanov
2025-01-28 12:10:28 +00:00
committed by Anton Tolchanov
parent 6f10fe8ab1
commit 3abfbf50ae
2 changed files with 35 additions and 3 deletions

View File

@@ -1286,11 +1286,12 @@ type listener struct {
}
func (ln *listener) Accept() (net.Conn, error) {
c, ok := <-ln.conn
if !ok {
select {
case c := <-ln.conn:
return c, nil
case <-ln.closedc:
return nil, fmt.Errorf("tsnet: %w", net.ErrClosed)
}
return c, nil
}
func (ln *listener) Addr() net.Addr { return addr{ln} }