From 0c34fc7b5b1a8a0c61ad079ca4776d33a3c262d8 Mon Sep 17 00:00:00 2001 From: James Tucker Date: Thu, 25 Aug 2022 10:34:25 -0700 Subject: [PATCH] net/tstun: remove buffer on outbound channel The buffer is not necessary, I was unable to observe any optimization, and having an unbuffered channel offers potential scheduler optimization. Signed-off-by: James Tucker --- net/tstun/wrap.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/tstun/wrap.go b/net/tstun/wrap.go index 658c85eff..80b129279 100644 --- a/net/tstun/wrap.go +++ b/net/tstun/wrap.go @@ -202,10 +202,9 @@ func wrap(logf logger.Logf, tdev tun.Device, isTAP bool) *Wrapper { // a goroutine should not block when setting it, even with no listeners. bufferConsumed: make(chan struct{}, 1), closed: make(chan struct{}), - // outbound can be unbuffered; the buffer is an optimization. - outbound: make(chan tunReadResult, 1), - eventsUpDown: make(chan tun.Event), - eventsOther: make(chan tun.Event), + outbound: make(chan tunReadResult), + eventsUpDown: make(chan tun.Event), + eventsOther: make(chan tun.Event), // TODO(dmytro): (highly rate-limited) hexdumps should happen on unknown packets. filterFlags: filter.LogAccepts | filter.LogDrops, }