cmd/tailscale: wait for previous tunnel(s) to close before establishing new

Signed-off-by: Elias Naur <mail@eliasnaur.com>
pull/3/head
Elias Naur 4 years ago
parent e77dcd9933
commit b297135f2a

@ -29,6 +29,7 @@ type multiTUN struct {
mtus chan chan mtuReply
names chan chan nameReply
shutdowns chan struct{}
shutdownDone chan struct{}
}
// tunDevice wraps and drives a single run.Device.
@ -74,6 +75,7 @@ func newTUNDevices() *multiTUN {
mtus: make(chan chan mtuReply),
names: make(chan chan nameReply),
shutdowns: make(chan struct{}),
shutdownDone: make(chan struct{}),
}
go d.run()
return d
@ -112,6 +114,7 @@ func (d *multiTUN) run() {
<-dev.readDone
}
devices = nil
d.shutdownDone <- struct{}{}
case <-d.close:
var derr error
for _, dev := range devices {
@ -279,6 +282,7 @@ func (d *multiTUN) Events() chan tun.Event {
func (d *multiTUN) Shutdown() {
d.shutdowns <- struct{}{}
<-d.shutdownDone
}
func (d *multiTUN) Close() error {

Loading…
Cancel
Save