Skip to content

Commit 2ad2d4d

Browse files
authored
wgengine/magicsock: fix UDPRelayAllocReq/Resp deadlock (tailscale#17831)
Updates tailscale#17830 Signed-off-by: Jordan Whited <[email protected]>
1 parent 18806de commit 2ad2d4d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

wgengine/magicsock/magicsock.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2444,7 +2444,10 @@ func (c *Conn) handleDiscoMessage(msg []byte, src epAddr, shouldBeRelayHandshake
24442444
if !nodeHasCap(c.filt, c.peers.At(peerI), c.self, tailcfg.PeerCapabilityRelay) {
24452445
return
24462446
}
2447-
c.allocRelayEndpointPub.Publish(UDPRelayAllocReq{
2447+
// [Conn.mu] must not be held while publishing, or [Conn.onUDPRelayAllocResp]
2448+
// can deadlock as the req sub and resp pub are the same goroutine.
2449+
// See #17830.
2450+
go c.allocRelayEndpointPub.Publish(UDPRelayAllocReq{
24482451
RxFromDiscoKey: sender,
24492452
RxFromNodeKey: nodeKey,
24502453
Message: req,

0 commit comments

Comments
 (0)