summaryrefslogtreecommitdiffhomepage
path: root/conn.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-05-20 06:19:29 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-05-20 06:29:21 +0200
commit1068d6b92b905adef34525fbac37a5af7290f4fa (patch)
tree489aecd3861ff1592d358c8787084e1b89fee036 /conn.go
parent5e924e540764ec64cdf19f9b146a3c398da4d240 (diff)
Give bind its own wait group
In a waitgroup, all waits must come after all adds
Diffstat (limited to 'conn.go')
-rw-r--r--conn.go6
1 files changed, 4 insertions, 2 deletions
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")
}