Skip to content

Commit af67175

Browse files
committed
SpreadWriter: fix flush panic with zero writes
1 parent b28153e commit af67175

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

internal/writers/spread_writer.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ func (s *SpreadWriter) Write(p []byte) (int, error) {
2929
}
3030

3131
func (s *SpreadWriter) Flush() {
32+
if len(s.buf) == 0 {
33+
// nothing to write, just wait
34+
select {
35+
case <-time.After(s.interval):
36+
case <-s.exitCh:
37+
}
38+
return
39+
}
3240
sleep := s.interval / time.Duration(len(s.buf))
3341
ticker := time.NewTicker(sleep)
3442
for _, b := range s.buf {

0 commit comments

Comments
 (0)