From 33d0e824c73a918ad59586084b47cd53fe07ca36 Mon Sep 17 00:00:00 2001 From: Amanda Tait Date: Tue, 26 Feb 2019 09:09:42 -0800 Subject: Use more conservative locking in NIC.DeliverNetworkPacket An earlier CL excessively minimizes the period in which it holds a lock on NIC. This earlier CL had done this out of the mistaken impression it fixed a broken test, when in fact it just reduced the rate of failure of a flaky test in tcp_test.go. This new change holds the lock on NIC for the duration of the loop over n.endpoints. PiperOrigin-RevId: 235732487 Change-Id: I53ee6df264f093ddc4d29e9acdcba6b4838cb112 --- pkg/tcpip/stack/nic.go | 2 -- 1 file changed, 2 deletions(-) (limited to 'pkg/tcpip/stack/nic.go') diff --git a/pkg/tcpip/stack/nic.go b/pkg/tcpip/stack/nic.go index a6b04faaf..2278fbf65 100644 --- a/pkg/tcpip/stack/nic.go +++ b/pkg/tcpip/stack/nic.go @@ -406,14 +406,12 @@ func (n *NIC) DeliverNetworkPacket(linkEP LinkEndpoint, remote, _ tcpip.LinkAddr // n.endpoints is mutex protected so acquire lock. n.mu.RLock() for _, ref := range n.endpoints { - n.mu.RUnlock() if ref.protocol == header.IPv4ProtocolNumber && ref.tryIncRef() { r := makeRoute(protocol, dst, src, linkEP.LinkAddress(), ref) r.RemoteLinkAddress = remote ref.ep.HandlePacket(&r, vv) ref.decRef() } - n.mu.RLock() } n.mu.RUnlock() return -- cgit v1.2.3