From 077f22fc525a9c2a47c5cb63b5fd83017a743a65 Mon Sep 17 00:00:00 2001 From: bakape Date: Sat, 4 Mar 2017 11:14:50 +0200 Subject: [PATCH] server/websokets: Fix client message buffer overflowing --- go/src/meguca/server/websockets/websockets.go | 5 ++--- go/src/meguca/util/util.go | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/go/src/meguca/server/websockets/websockets.go b/go/src/meguca/server/websockets/websockets.go index 0fe1c8622..d92dcc45d 100644 --- a/go/src/meguca/server/websockets/websockets.go +++ b/go/src/meguca/server/websockets/websockets.go @@ -99,9 +99,8 @@ func newClient(conn *websocket.Conn, req *http.Request) *Client { close: make(chan error, 2), receive: make(chan receivedMessage), redirect: make(chan string), - // Allows for ~6 seconds of messages at 0.2 second intervals, until the - // buffer overflows. - sendExternal: make(chan []byte, 1<<5), + // Allows for ~6 seconds of messages , until the buffer overflows + sendExternal: make(chan []byte, time.Second*6/util.TickerInterval), conn: conn, } } diff --git a/go/src/meguca/util/util.go b/go/src/meguca/util/util.go index 3ab77d4ed..78ff871e1 100644 --- a/go/src/meguca/util/util.go +++ b/go/src/meguca/util/util.go @@ -9,6 +9,9 @@ import ( "time" ) +// TickerInterval sets the interval of PausableTicker flushes +const TickerInterval = time.Millisecond * 100 + // PausableTicker is a time.Ticker that can be paused type PausableTicker struct { t *time.Ticker @@ -17,7 +20,7 @@ type PausableTicker struct { // Start starts p func (p *PausableTicker) Start() { - p.t = time.NewTicker(time.Millisecond * 50) + p.t = time.NewTicker(TickerInterval) p.C = p.t.C }