We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b2101a5 commit f7db75aCopy full SHA for f7db75a
internal/gameServer/tcp.go
@@ -152,7 +152,14 @@ func (g *GameServer) processTCP(conn *net.TCPConn) {
152
tcpData := &TCPData{Request: RequestNone}
153
incomingBuffer := make([]byte, 1500) //nolint:gomnd,mnd
154
for {
155
- err := conn.SetReadDeadline(time.Now().Add(time.Millisecond))
+ var readDeadline time.Time
156
+ if tcpData.Buffer.Len() > 0 {
157
+ // if there is pending data in the buffer, get to it quickly
158
+ readDeadline = time.Now().Add(time.Millisecond)
159
+ } else {
160
+ readDeadline = time.Now().Add(time.Second)
161
+ }
162
+ err := conn.SetReadDeadline(readDeadline)
163
if err != nil {
164
g.Logger.Error(err, "could not set read deadline", "address", conn.RemoteAddr().String())
165
}
0 commit comments