From 3516ccc1e226756c4ba6d431cbf7e3a3fe63c5f8 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 8 Feb 2021 10:19:28 -0800 Subject: [PATCH] device: remove device.state.stopping from RoutineTUNEventReader The TUN event reader does three things: Change MTU, device up, and device down. Changing the MTU after the device is closed does no harm. Device up and device down don't make sense after the device is closed, but we can check that condition before proceeding with changeState. There's thus no reason to block device.Close on RoutineTUNEventReader exiting. Signed-off-by: Josh Bleecher Snyder --- device/device.go | 2 +- device/tun.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/device/device.go b/device/device.go index c637e38..52b0143 100644 --- a/device/device.go +++ b/device/device.go @@ -383,7 +383,7 @@ func NewDevice(tunDevice tun.Device, logger *Logger) *Device { go device.RoutineHandshake() } - device.state.stopping.Add(2) + device.state.stopping.Add(1) // read from TUN go device.RoutineReadFromTUN() go device.RoutineTUNEventReader() diff --git a/device/tun.go b/device/tun.go index ca3c91b..9ff6c23 100644 --- a/device/tun.go +++ b/device/tun.go @@ -47,5 +47,4 @@ func (device *Device) RoutineTUNEventReader() { } device.log.Verbosef("Routine: event worker - stopped") - device.state.stopping.Done() }