Skip to content

Commit

Permalink
Use pointer for wrappedConn methods (#17295)
Browse files Browse the repository at this point in the history
Fix #17294

Signed-off-by: Andrew Thornton <art27@cantab.net>
  • Loading branch information
zeripath authored Oct 12, 2021
1 parent 7bcbdd0 commit 429258c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/graceful/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (wl *wrappedListener) Accept() (net.Conn, error) {

closed := int32(0)

c = wrappedConn{
c = &wrappedConn{
Conn: c,
server: wl.server,
closed: &closed,
Expand Down Expand Up @@ -263,7 +263,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)
Expand All @@ -277,7 +277,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 {
Expand Down

0 comments on commit 429258c

Please sign in to comment.