From: Jason A. Donenfeld Date: Tue, 26 Sep 2017 13:24:18 +0000 (+0200) Subject: Sleep to close fd X-Git-Tag: 0.0.20180514~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32d8932d1b29effa42fe56822988d3888c496873;p=thirdparty%2Fwireguard-go.git Sleep to close fd --- diff --git a/src/conn.go b/src/conn.go index 41a5b85..2cf588d 100644 --- a/src/conn.go +++ b/src/conn.go @@ -3,6 +3,7 @@ package main import ( "errors" "net" + "time" ) func parseEndpoint(s string) (*net.UDPAddr, error) { @@ -36,6 +37,10 @@ func updateUDPConn(device *Device) error { if netc.conn != nil { netc.conn.Close() netc.conn = nil + + // We need for that fd to be closed in all other go routines, which + // means we have to wait. TODO: find less horrible way of doing this. + time.Sleep(time.Second / 2) } // open new connection