Skip to content

Commit

Permalink
refactor: Close the socketstream lines channel only once.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaqx0r committed Jul 5, 2024
1 parent cf3931d commit f39cf7b
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions internal/tailer/logstream/socketstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit f39cf7b

Please sign in to comment.