Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

Commit

Permalink
server/websokets: Fix client message buffer overflowing
Browse files Browse the repository at this point in the history
  • Loading branch information
bakape committed Mar 4, 2017
1 parent 7ef7277 commit 077f22f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 2 additions & 3 deletions go/src/meguca/server/websockets/websockets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
5 changes: 4 additions & 1 deletion go/src/meguca/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down

0 comments on commit 077f22f

Please sign in to comment.