mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
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:
parent
e852fdd89f
commit
8b178a93c1
@ -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...)
|
||||
|
Loading…
x
Reference in New Issue
Block a user