From aabc3770bad3ac6674a7a3952cdcd88f11dd1a72 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 10 Feb 2021 00:43:31 +0100 Subject: conn: close old fd before trying again Signed-off-by: Jason A. Donenfeld --- conn/conn_default.go | 1 + conn/conn_linux.go | 1 + 2 files changed, 2 insertions(+) (limited to 'conn') diff --git a/conn/conn_default.go b/conn/conn_default.go index 2360068..82a1e42 100644 --- a/conn/conn_default.go +++ b/conn/conn_default.go @@ -99,6 +99,7 @@ again: bind.ipv6, port, err = listenNet("udp6", port) if uport == 0 && err != nil && errors.Is(err, syscall.EADDRINUSE) && tries < 100 { + bind.ipv4.Close() tries++ goto again } diff --git a/conn/conn_linux.go b/conn/conn_linux.go index 716028f..f07c3bb 100644 --- a/conn/conn_linux.go +++ b/conn/conn_linux.go @@ -123,6 +123,7 @@ again: bind.sock4, newPort, err = create4(port) if err != nil { if originalPort == 0 && err == syscall.EADDRINUSE && tries < 100 { + unix.Close(bind.sock6) tries++ goto again } -- cgit v1.2.3