pkg/broadcastwriter: reset after 4 KB w/o stream
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
This commit is contained in:
parent
61ad4654f5
commit
d9fa79b73c
1 changed files with 5 additions and 2 deletions
|
@ -42,9 +42,12 @@ func (w *BroadcastWriter) Write(p []byte) (n int, err error) {
|
||||||
delete(writers, sw)
|
delete(writers, sw)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// exit if there is no more writers
|
|
||||||
if len(w.streams) == 1 {
|
if len(w.streams) == 1 {
|
||||||
w.buf.Reset()
|
if w.buf.Len() >= 4096 {
|
||||||
|
w.buf.Reset()
|
||||||
|
} else {
|
||||||
|
w.buf.Write(p)
|
||||||
|
}
|
||||||
w.Unlock()
|
w.Unlock()
|
||||||
return len(p), nil
|
return len(p), nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue