Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
appease the linter some more
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
  • Loading branch information
mohammed90 committed Mar 25, 2025
commit e42cf4fc80f3accd6b5136a2fefa5facfdd4aa42
18 changes: 9 additions & 9 deletions listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (fcl *fakeCloseListener) Accept() (net.Conn, error) {
}

// call underlying accept
conn, err := fcl.sharedListener.Accept()
conn, err := fcl.Accept()
if err == nil {
// if 0, do nothing, Go's default is already set
// and if the connection allows setting KeepAlive, set it
Expand All @@ -147,7 +147,7 @@ func (fcl *fakeCloseListener) Accept() (net.Conn, error) {
err = tconn.SetKeepAlive(false)
}
if err != nil {
Log().With(zap.String("server", fcl.sharedListener.key)).Warn("unable to set keepalive for new connection:", zap.Error(err))
Log().With(zap.String("server", fcl.key)).Warn("unable to set keepalive for new connection:", zap.Error(err))
}
}
return conn, nil
Expand All @@ -165,7 +165,7 @@ func (fcl *fakeCloseListener) Accept() (net.Conn, error) {
// users of this listener, not just our own reference to it; we also don't
// do anything with the error because all we could do is log it, but we
// explicitly assign it to nothing so we don't forget it's there if needed
_ = fcl.sharedListener.clearDeadline()
_ = fcl.clearDeadline()

if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
return nil, fakeClosedErr(fcl)
Expand All @@ -188,8 +188,8 @@ func (fcl *fakeCloseListener) Close() error {
// file). But we can set the deadline in the past,
// and this is kind of cheating, but it works, and
// it apparently even works on Windows.
_ = fcl.sharedListener.setDeadline()
_, _ = listenerPool.Delete(fcl.sharedListener.key)
_ = fcl.setDeadline()
_, _ = listenerPool.Delete(fcl.key)
}
return nil
}
Expand Down Expand Up @@ -236,7 +236,7 @@ func (sl *sharedListener) setDeadline() error {
// Destruct is called by the UsagePool when the listener is
// finally not being used anymore. It closes the socket.
func (sl *sharedListener) Destruct() error {
return sl.Listener.Close()
return sl.Close()
}

// fakeClosePacketConn is like fakeCloseListener, but for PacketConns,
Expand Down Expand Up @@ -279,13 +279,13 @@ func (fcpc *fakeClosePacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err e
func (fcpc *fakeClosePacketConn) Close() error {
if atomic.CompareAndSwapInt32(&fcpc.closed, 0, 1) {
_ = fcpc.SetReadDeadline(time.Now()) // unblock ReadFrom() calls to kick old servers out of their loops
_, _ = listenerPool.Delete(fcpc.sharedPacketConn.key)
_, _ = listenerPool.Delete(fcpc.key)
}
return nil
}

func (fcpc *fakeClosePacketConn) Unwrap() net.PacketConn {
return fcpc.sharedPacketConn.PacketConn
return fcpc.PacketConn
}

// sharedPacketConn is like sharedListener, but for net.PacketConns.
Expand All @@ -296,7 +296,7 @@ type sharedPacketConn struct {

// Destruct closes the underlying socket.
func (spc *sharedPacketConn) Destruct() error {
return spc.PacketConn.Close()
return spc.Close()
}

// Unwrap returns the underlying socket
Expand Down
Loading