Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
hmaurer committed Nov 7, 2023
1 parent 615ca5e commit b821074
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go/mysql/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions go/netutil/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b821074

Please sign in to comment.