1
1
mirror of https://github.com/go-gitea/gitea synced 2024-12-23 00:54:28 +00:00

Use pointer for wrappedConn methods (#17295)

Fix #17294

Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
zeripath 2021-10-12 21:55:18 +01:00 committed by GitHub
parent 7bcbdd0707
commit 429258cff3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -228,7 +228,7 @@ func (wl *wrappedListener) Accept() (net.Conn, error) {
closed := int32(0) closed := int32(0)
c = wrappedConn{ c = &wrappedConn{
Conn: c, Conn: c,
server: wl.server, server: wl.server,
closed: &closed, closed: &closed,
@ -263,7 +263,7 @@ type wrappedConn struct {
perWritePerKbTimeout time.Duration 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 { if w.perWriteTimeout > 0 {
minTimeout := time.Duration(len(p)/1024) * w.perWritePerKbTimeout minTimeout := time.Duration(len(p)/1024) * w.perWritePerKbTimeout
minDeadline := time.Now().Add(minTimeout).Add(w.perWriteTimeout) minDeadline := time.Now().Add(minTimeout).Add(w.perWriteTimeout)
@ -277,7 +277,7 @@ func (w wrappedConn) Write(p []byte) (n int, err error) {
return w.Conn.Write(p) return w.Conn.Write(p)
} }
func (w wrappedConn) Close() error { func (w *wrappedConn) Close() error {
if atomic.CompareAndSwapInt32(w.closed, 0, 1) { if atomic.CompareAndSwapInt32(w.closed, 0, 1) {
defer func() { defer func() {
if err := recover(); err != nil { if err := recover(); err != nil {