netstack: clear buckets upon close

It was possible for `close` and `dispatch` to race, each trying to `DecRef` the
same packet. We now clear the bucket of packets upon `close` so that `DecRef`
occurs only once.

PiperOrigin-RevId: 540663408
This commit is contained in:
Kevin Krakauer
2023-06-15 12:51:59 -07:00
committed by gVisor bot
parent 90bf8f22fc
commit 12f6b63c31
+2 -1
View File
@@ -678,8 +678,9 @@ func (gd *groDispatcher) close() {
for i := range gd.buckets {
bucket := &gd.buckets[i]
bucket.mu.Lock()
for groPkt := bucket.packets.Front(); groPkt != nil; groPkt = groPkt.Next() {
for groPkt := bucket.packets.Front(); groPkt != nil; groPkt = bucket.packets.Front() {
groPkt.pkt.DecRef()
bucket.removeOne(groPkt)
}
bucket.mu.Unlock()
}