From f39cf7b6a0d793215af3fd73d255169e3c40da6d Mon Sep 17 00:00:00 2001 From: Jamie Wilkinson Date: Thu, 4 Jul 2024 16:22:06 +0200 Subject: [PATCH] refactor: Close the socketstream lines channel only once. --- internal/tailer/logstream/socketstream.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/internal/tailer/logstream/socketstream.go b/internal/tailer/logstream/socketstream.go index 3e5f51dab..6f275b67f 100644 --- a/internal/tailer/logstream/socketstream.go +++ b/internal/tailer/logstream/socketstream.go @@ -28,7 +28,6 @@ type socketStream struct { lastReadTime time.Time // Last time a log line was read from this socket staleTimer *time.Timer // Expire the stream if no read in 24h - } func newSocketStream(ctx context.Context, wg *sync.WaitGroup, waker waker.Waker, scheme, address string, oneShot OneShotMode) (LogStream, error) { @@ -73,9 +72,7 @@ func (ss *socketStream) stream(ctx context.Context, wg *sync.WaitGroup, waker wa glog.Info(err) } connWg.Wait() - if !ss.oneShot { - close(ss.lines) - } + close(ss.lines) }() var connOnce sync.Once @@ -117,9 +114,6 @@ func (ss *socketStream) handleConn(ctx context.Context, wg *sync.WaitGroup, wake glog.Info(err) } logCloses.Add(ss.address, 1) - if ss.oneShot { - close(ss.lines) - } }() ctx, cancel := context.WithCancel(ctx) defer cancel()