mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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
This commit is contained in:
committed by
Shentubot
parent
a949133c4b
commit
e4b395db49
@@ -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.
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"encoding/binary"
|
||||
"sync"
|
||||
|
||||
"gvisor.googlesource.com/gvisor/pkg/sleep"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip/buffer"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip/header"
|
||||
@@ -274,13 +273,8 @@ func (e *endpoint) Write(p tcpip.Payload, opts tcpip.WriteOptions) (uintptr, <-c
|
||||
}
|
||||
|
||||
if route.IsResolutionRequired() {
|
||||
waker := &sleep.Waker{}
|
||||
if ch, err := route.Resolve(waker); err != nil {
|
||||
if ch, err := route.Resolve(nil); err != nil {
|
||||
if err == tcpip.ErrWouldBlock {
|
||||
// Link address needs to be resolved.
|
||||
// Resolution was triggered the background.
|
||||
// Better luck next time.
|
||||
route.RemoveWaker(waker)
|
||||
return 0, ch, tcpip.ErrNoLinkAddress
|
||||
}
|
||||
return 0, nil, err
|
||||
|
||||
@@ -29,7 +29,6 @@ package raw
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"gvisor.googlesource.com/gvisor/pkg/sleep"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip/buffer"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip/header"
|
||||
@@ -259,13 +258,8 @@ func (ep *endpoint) finishWrite(payload tcpip.Payload, route *stack.Route) (uint
|
||||
// network address). If that requires blocking (e.g. to use ARP),
|
||||
// return a channel on which the caller can wait.
|
||||
if route.IsResolutionRequired() {
|
||||
waker := &sleep.Waker{}
|
||||
if ch, err := route.Resolve(waker); err != nil {
|
||||
if ch, err := route.Resolve(nil); err != nil {
|
||||
if err == tcpip.ErrWouldBlock {
|
||||
// Link address needs to be resolved.
|
||||
// Resolution was triggered the background.
|
||||
// Better luck next time.
|
||||
route.RemoveWaker(waker)
|
||||
return 0, ch, tcpip.ErrNoLinkAddress
|
||||
}
|
||||
return 0, nil, err
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"math"
|
||||
"sync"
|
||||
|
||||
"gvisor.googlesource.com/gvisor/pkg/sleep"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip/buffer"
|
||||
"gvisor.googlesource.com/gvisor/pkg/tcpip/header"
|
||||
@@ -346,12 +345,8 @@ func (e *endpoint) Write(p tcpip.Payload, opts tcpip.WriteOptions) (uintptr, <-c
|
||||
}
|
||||
|
||||
if route.IsResolutionRequired() {
|
||||
waker := &sleep.Waker{}
|
||||
if ch, err := route.Resolve(waker); err != nil {
|
||||
if ch, err := route.Resolve(nil); err != nil {
|
||||
if err == tcpip.ErrWouldBlock {
|
||||
// Link address needs to be resolved. Resolution was triggered the background.
|
||||
// Better luck next time.
|
||||
route.RemoveWaker(waker)
|
||||
return 0, ch, tcpip.ErrNoLinkAddress
|
||||
}
|
||||
return 0, nil, err
|
||||
|
||||
Reference in New Issue
Block a user