Skip to content

Commit

Permalink
Use pointer for wrappedConn methods (go-gitea#17295)
Browse files Browse the repository at this point in the history
Backport go-gitea#17295

Fix go-gitea#17294

Signed-off-by: Andrew Thornton <art27@cantab.net>
  • Loading branch information
zeripath committed Oct 12, 2021
1 parent fde6ff6 commit ff0ab86
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 @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit ff0ab86

Please sign in to comment.