From 32d8932d1b29effa42fe56822988d3888c496873 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 26 Sep 2017 15:24:18 +0200 Subject: Sleep to close fd --- src/conn.go | 5 +++++ 1 file changed, 5 insertions(+) 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 -- cgit v1.2.3