playground/socket: fix message buffering

Use time.After to avoid the finnicky antics of
correctly resetting a time.Timer.

Fixes golang/go#13749

Change-Id: I3f1ed17a31d981996e2bb7a8155c3ba0ec723c7d
Reviewed-on: https://go-review.googlesource.com/19942
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
This commit is contained in:
Andrew Gerrand 2016-02-26 15:47:36 +11:00
parent e852fdd89f
commit 8b178a93c1

View File

@ -264,7 +264,6 @@ func buffer(in <-chan *Message) <-chan *Message {
go func() {
defer close(out)
var (
t = time.NewTimer(msgDelay)
tc <-chan time.Time
buf []byte
kind string
@ -293,8 +292,7 @@ func buffer(in <-chan *Message) <-chan *Message {
flush()
kind = m.Kind
if tc == nil {
tc = t.C
t.Reset(msgDelay)
tc = time.After(msgDelay)
}
}
buf = append(buf, m.Body...)