Skip to content

Commit

Permalink
Remove SetLinger on TCP connections (ava-labs#2150)
Browse files Browse the repository at this point in the history
Co-authored-by: Joshua Kim <[email protected]>
  • Loading branch information
patrick-ogrady and joshua-kim authored Oct 26, 2022
1 parent 63f32a8 commit 040990c
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -928,16 +928,6 @@ func (n *network) dial(ctx context.Context, nodeID ids.NodeID, ip *trackedIP) {
// connection will be used to create a new peer. Otherwise the connection will
// be immediately closed.
func (n *network) upgrade(conn net.Conn, upgrader peer.Upgrader) error {
if conn, ok := conn.(*net.TCPConn); ok {
// If a connection is closed, we shouldn't bother keeping any messages
// in memory.
if err := conn.SetLinger(0); err != nil {
n.peerConfig.Log.Warn("failed to set no linger",
zap.Error(err),
)
}
}

upgradeTimeout := n.peerConfig.Clock.Time().Add(n.config.ReadHandshakeTimeout)
if err := conn.SetReadDeadline(upgradeTimeout); err != nil {
_ = conn.Close()
Expand Down

0 comments on commit 040990c

Please sign in to comment.