Skip to content

Commit

Permalink
Use pointer for wrappedConn methods
Browse files Browse the repository at this point in the history
Fix go-gitea#17294

Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath committed Oct 12, 2021
1 parent 7bcbdd0 commit 4045684
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 4045684

Please sign in to comment.