File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import (
1212 "os"
1313 "strings"
1414 "sync"
15+ "sync/atomic"
1516 "syscall"
1617 "time"
1718
@@ -215,9 +216,12 @@ func (wl *wrappedListener) Accept() (net.Conn, error) {
215216 }
216217 }
217218
219+ closed := int32 (0 )
220+
218221 c = wrappedConn {
219222 Conn : c ,
220223 server : wl .server ,
224+ closed : & closed ,
221225 }
222226
223227 wl .server .wg .Add (1 )
@@ -241,12 +245,12 @@ func (wl *wrappedListener) File() (*os.File, error) {
241245type wrappedConn struct {
242246 net.Conn
243247 server * Server
248+ closed * int32
244249}
245250
246251func (w wrappedConn ) Close () error {
247- err := w .Conn .Close ()
248- if err == nil {
252+ if atomic .CompareAndSwapInt32 (w .closed , 0 , 1 ) {
249253 w .server .wg .Done ()
250254 }
251- return err
255+ return w . Conn . Close ()
252256}
You can’t perform that action at this time.
0 commit comments