feature/relayserver: don't publish from within a subscribe fn goroutine
Updates #17830 Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
committed by
Jordan Whited
parent
e7f5ca1d5e
commit
9245c7131b
@@ -147,7 +147,12 @@ func (e *extension) onAllocReq(req magicsock.UDPRelayAllocReq) {
|
|||||||
e.logf("error allocating endpoint: %v", err)
|
e.logf("error allocating endpoint: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.respPub.Publish(magicsock.UDPRelayAllocResp{
|
// Take a defensive stance around publishing from within an
|
||||||
|
// [*eventbus.SubscribeFunc] by publishing from a separate goroutine. At the
|
||||||
|
// time of writing (2025-11-21), publishing from within the
|
||||||
|
// [*eventbus.SubscribeFunc] goroutine is potentially unsafe if publisher
|
||||||
|
// and subscriber share a lock.
|
||||||
|
go e.respPub.Publish(magicsock.UDPRelayAllocResp{
|
||||||
ReqRxFromNodeKey: req.RxFromNodeKey,
|
ReqRxFromNodeKey: req.RxFromNodeKey,
|
||||||
ReqRxFromDiscoKey: req.RxFromDiscoKey,
|
ReqRxFromDiscoKey: req.RxFromDiscoKey,
|
||||||
Message: &disco.AllocateUDPRelayEndpointResponse{
|
Message: &disco.AllocateUDPRelayEndpointResponse{
|
||||||
|
|||||||
Reference in New Issue
Block a user