From 7d1c03d2ac5f21f6e6d8a894c547dee7eaa1a145 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 17 Jul 2019 12:07:16 +0100 Subject: [PATCH] Only call stillAlive if channel read succeeds --- src/tuntap/conn.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tuntap/conn.go b/src/tuntap/conn.go index c9afa6e1..c5e6e81b 100644 --- a/src/tuntap/conn.go +++ b/src/tuntap/conn.go @@ -86,7 +86,7 @@ func (s *tunConn) reader() error { }() for { select { - case r := <-read: + case r, ok := <-read: if r && n > 0 { bs := append(util.GetBytes(), b[:n]...) select { @@ -95,7 +95,9 @@ func (s *tunConn) reader() error { util.PutBytes(bs) } } - s.stillAlive() // TODO? Only stay alive if we read >0 bytes? + if ok { + s.stillAlive() // TODO? Only stay alive if we read >0 bytes? + } case <-s.stop: return nil }