pkg/broadcastwriter: reset after 4 KB w/o stream

Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
This commit is contained in:
unclejack 2015-04-01 00:23:04 +03:00
parent d15d1674c3
commit 153f98bad5

View file

@ -42,9 +42,12 @@ func (w *BroadcastWriter) Write(p []byte) (n int, err error) {
delete(writers, sw)
}
}
// exit if there is no more writers
if len(w.streams) == 1 {
w.buf.Reset()
if w.buf.Len() >= 4096 {
w.buf.Reset()
} else {
w.buf.Write(p)
}
w.Unlock()
return len(p), nil
}