From 8b178a93c1f5b5c8f4e36cd6bd64e0d5bf0ee180 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Fri, 26 Feb 2016 15:47:36 +1100 Subject: [PATCH] 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 --- playground/socket/socket.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/playground/socket/socket.go b/playground/socket/socket.go index cec842e5..527c0755 100644 --- a/playground/socket/socket.go +++ b/playground/socket/socket.go @@ -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...)