device: signal to close device in separate routine

Otherwise we wind up deadlocking.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2021-03-11 09:29:10 -07:00
parent c5f382624e
commit 5f0c8b942d

View File

@ -228,7 +228,7 @@ func (device *Device) RoutineReadFromTUN() {
if err != nil {
if !device.isClosed() {
device.log.Errorf("Failed to read packet from TUN device: %v", err)
device.Close()
go device.Close()
}
device.PutMessageBuffer(elem.buffer)
device.PutOutboundElement(elem)