From 1068d6b92b905adef34525fbac37a5af7290f4fa Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 20 May 2018 06:19:29 +0200 Subject: Give bind its own wait group In a waitgroup, all waits must come after all adds --- conn.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'conn.go') diff --git a/conn.go b/conn.go index b79b9cd..ded7419 100644 --- a/conn.go +++ b/conn.go @@ -75,6 +75,7 @@ func unsafeCloseBind(device *Device) error { err = netc.bind.Close() netc.bind = nil } + netc.stopping.Wait() return err } @@ -162,10 +163,11 @@ func (device *Device) BindUpdate() error { // start receiving routines - device.state.starting.Add(ConnRoutineNumber) - device.state.stopping.Add(ConnRoutineNumber) + device.net.starting.Add(ConnRoutineNumber) + device.net.stopping.Add(ConnRoutineNumber) go device.RoutineReceiveIncoming(ipv4.Version, netc.bind) go device.RoutineReceiveIncoming(ipv6.Version, netc.bind) + device.net.starting.Wait() device.log.Debug.Println("UDP bind has been updated") } -- cgit v1.2.3