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 61ad4654f5
commit d9fa79b73c

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 {
if w.buf.Len() >= 4096 {
w.buf.Reset()
} else {
w.buf.Write(p)
}
w.Unlock()
return len(p), nil
}