Commit 52ad3d38 authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Upper bound on socket buffer sizes.

parent 9e63af30
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -7,6 +7,9 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
### Added
- Print a log message when all authoritative messages have stopped during graceful shutdown.

### Changed
- Upper bound on socket buffer sizes. Flush buffer more than once per message if payload size exceeds buffer size.

## [2.11.1] - 2020-03-29
### Changed
- Update protobuf (1.3.5), websocket (1.4.2), opencensus (0.22.3), atomic (1.6.0), zap (1.14.1) dependencies.
+7 −2
Original line number Diff line number Diff line
@@ -29,9 +29,14 @@ import (
var SocketWsStatsCtx = context.Background()

func NewSocketWsAcceptor(logger *zap.Logger, config Config, sessionRegistry SessionRegistry, matchmaker Matchmaker, tracker Tracker, runtime *Runtime, jsonpbMarshaler *jsonpb.Marshaler, jsonpbUnmarshaler *jsonpb.Unmarshaler, pipeline *Pipeline) func(http.ResponseWriter, *http.Request) {
	// Select buffer size based on max message size, but cap it to 512KB total (256KB read, 256KB write).
	bufferSize := 256 * 1024
	if maxMessageSizeBytes := int(config.GetSocket().MaxMessageSizeBytes); maxMessageSizeBytes < bufferSize {
		bufferSize = maxMessageSizeBytes
	}
	upgrader := &websocket.Upgrader{
		ReadBufferSize:  int(config.GetSocket().MaxMessageSizeBytes),
		WriteBufferSize: int(config.GetSocket().MaxMessageSizeBytes),
		ReadBufferSize:  bufferSize,
		WriteBufferSize: bufferSize,
		CheckOrigin:     func(r *http.Request) bool { return true },
	}