summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/stack
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@google.com>2019-05-24 12:28:15 -0700
committerShentubot <shentubot@google.com>2019-05-24 12:29:14 -0700
commite4b395db49e9e90659bd3d366f62aa258a3c7157 (patch)
treecd5dc7688d066671f0323ab47951999e21c62839 /pkg/tcpip/stack
parenta949133c4b22a87c79310b2d825f2899028d6088 (diff)
Remove unused wakers
These wakers are uselessly allocated and passed around; nothing ever listens for notifications on them. The code here appears to be vestigial, so removing it and allowing a nil waker to be passed seems appropriate. PiperOrigin-RevId: 249879320 Change-Id: Icd209fb77cc0dd4e5c49d7a9f2adc32bf88b4b71
Diffstat (limited to 'pkg/tcpip/stack')
-rw-r--r--pkg/tcpip/stack/linkaddrcache.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/pkg/tcpip/stack/linkaddrcache.go b/pkg/tcpip/stack/linkaddrcache.go
index 42b9768ae..b952ad20f 100644
--- a/pkg/tcpip/stack/linkaddrcache.go
+++ b/pkg/tcpip/stack/linkaddrcache.go
@@ -138,8 +138,10 @@ func (e *linkAddrEntry) changeState(ns entryState) {
e.s = ns
}
-func (e *linkAddrEntry) addWaker(w *sleep.Waker) {
- e.wakers[w] = struct{}{}
+func (e *linkAddrEntry) maybeAddWaker(w *sleep.Waker) {
+ if w != nil {
+ e.wakers[w] = struct{}{}
+ }
}
func (e *linkAddrEntry) removeWaker(w *sleep.Waker) {
@@ -217,7 +219,7 @@ func (c *linkAddrCache) get(k tcpip.FullAddress, linkRes LinkAddressResolver, lo
return "", nil, tcpip.ErrNoLinkAddress
case incomplete:
// Address resolution is still in progress.
- entry.addWaker(waker)
+ entry.maybeAddWaker(waker)
return "", entry.done, tcpip.ErrWouldBlock
default:
panic(fmt.Sprintf("invalid cache entry state: %s", s))
@@ -230,7 +232,7 @@ func (c *linkAddrCache) get(k tcpip.FullAddress, linkRes LinkAddressResolver, lo
// Add 'incomplete' entry in the cache to mark that resolution is in progress.
e := c.makeAndAddEntry(k, "")
- e.addWaker(waker)
+ e.maybeAddWaker(waker)
go c.startAddressResolution(k, linkRes, localAddr, linkEP, e.done) // S/R-SAFE: link non-savable; wakers dropped synchronously.