From 1e278b15c2f04249e0e4654f2892581c8eb33645 Mon Sep 17 00:00:00 2001 From: zeripath Date: Tue, 12 Oct 2021 23:45:30 +0100 Subject: [PATCH] Use pointer for wrappedConn methods (#17295) (#17296) Backport #17295 Fix #17294 Signed-off-by: Andrew Thornton --- modules/graceful/server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/graceful/server.go b/modules/graceful/server.go index 6b7d4a1a970c..e98d3aa86b2b 100644 --- a/modules/graceful/server.go +++ b/modules/graceful/server.go @@ -229,7 +229,7 @@ func (wl *wrappedListener) Accept() (net.Conn, error) { closed := int32(0) - c = wrappedConn{ + c = &wrappedConn{ Conn: c, server: wl.server, closed: &closed, @@ -264,7 +264,7 @@ type wrappedConn struct { perWritePerKbTimeout time.Duration } -func (w wrappedConn) Write(p []byte) (n int, err error) { +func (w *wrappedConn) Write(p []byte) (n int, err error) { if w.perWriteTimeout > 0 { minTimeout := time.Duration(len(p)/1024) * w.perWritePerKbTimeout minDeadline := time.Now().Add(minTimeout).Add(w.perWriteTimeout) @@ -278,7 +278,7 @@ func (w wrappedConn) Write(p []byte) (n int, err error) { return w.Conn.Write(p) } -func (w wrappedConn) Close() error { +func (w *wrappedConn) Close() error { if atomic.CompareAndSwapInt32(w.closed, 0, 1) { defer func() { if err := recover(); err != nil {