]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
Sleep to close fd
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 26 Sep 2017 13:24:18 +0000 (15:24 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 26 Sep 2017 13:24:18 +0000 (15:24 +0200)
src/conn.go

index 41a5b855e36eaec5300524f51f51e233ce0f7c28..2cf588d8425eac98e054f0274e9b3760a1cc43f2 100644 (file)
@@ -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