Skip to content

Commit 920d8ab

Browse files
authored
Fix UDP conn cleanup (#31)
1 parent 866677b commit 920d8ab

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/transport/udp/udp.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
netipv6 "golang.org/x/net/ipv6"
2121

2222
"golang.zx2c4.com/wireguard/tun/netstack"
23-
"gvisor.dev/gvisor/pkg/buffer"
2423
"gvisor.dev/gvisor/pkg/tcpip"
2524
"gvisor.dev/gvisor/pkg/tcpip/header"
2625
"gvisor.dev/gvisor/pkg/tcpip/network/ipv4"
@@ -214,7 +213,7 @@ func handleConn(conn udpConn, port int, s *stack.Stack) {
214213
pktChan, _ := connMapLookup(conn)
215214
pkt := <-pktChan
216215
// Exit if packet is empty, other goroutine wants us to close.
217-
if pkt.IsNil() {
216+
if pkt == nil {
218217
return
219218
}
220219

@@ -252,15 +251,11 @@ func handleConn(conn udpConn, port int, s *stack.Stack) {
252251
}
253252
}
254253

255-
// Force closing of goroutine by reinjecting buffer (DecRef() to make nil pointer)
254+
// Force closing of goroutine by injecting nil pointer
256255
newConn.Close()
257256
pktChan, ok := connMapLookup(conn)
258257
if ok {
259-
nilPkt := stack.NewPacketBuffer(stack.PacketBufferOptions{
260-
Payload: buffer.MakeWithData([]byte{}),
261-
})
262-
nilPkt.DecRef()
263-
pktChan <- nilPkt
258+
pktChan <- nil
264259
}
265260
return
266261
}

0 commit comments

Comments
 (0)