From b821074e51095cf008eb99cc4d4c332752cc4a21 Mon Sep 17 00:00:00 2001 From: Henri Maurer Date: Tue, 7 Nov 2023 10:25:36 +0000 Subject: [PATCH] wip --- go/mysql/server.go | 2 +- go/netutil/conn.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go/mysql/server.go b/go/mysql/server.go index 7a5d61c8f18..efcf5a78eb8 100644 --- a/go/mysql/server.go +++ b/go/mysql/server.go @@ -522,7 +522,7 @@ func (l *Listener) handle(conn net.Conn, connectionID uint32, acceptTime time.Ti for { waitTimeout := 10 * time.Second - (&connWithTimeouts).SetNextReadTimeout(waitTimeout) + connWithTimeouts.SetNextReadTimeout(waitTimeout) kontinue := c.handleNextCommand(l.handler) if !kontinue { return diff --git a/go/netutil/conn.go b/go/netutil/conn.go index ddf3475a0ba..ab27d0a94dc 100644 --- a/go/netutil/conn.go +++ b/go/netutil/conn.go @@ -36,17 +36,17 @@ func NewConnWithTimeouts(conn net.Conn, readTimeout time.Duration, writeTimeout // Implementation of the Conn interface. // Read sets a read deadilne and delegates to conn.Read. -func (c ConnWithTimeouts) Read(b []byte) (int, error) { +func (c *ConnWithTimeouts) Read(b []byte) (int, error) { + defer func () { + c.nextReadTimeout = c.readTimeout; + }() if c.nextReadTimeout == 0 { return c.Conn.Read(b) } if err := c.Conn.SetReadDeadline(time.Now().Add(c.nextReadTimeout)); err != nil { return 0, err } - n, err := c.Conn.Read(b) - // how do I reset the read timeout here without a pointer receiver? - c.nextReadTimeout = c.readTimeout - return n, err + return c.Conn.Read(b) } // Write sets a write deadline and delegates to conn.Write