util/eventbus: don't allow publishers to skip events while debugging

If any debugging hook might see an event, Publisher.ShouldPublish should
tell its caller to publish even if there are no ordinary subscribers.

Updates #15160

Signed-off-by: David Anderson <dave@tailscale.com>
This commit is contained in:
David Anderson 2025-03-07 13:01:35 -08:00 committed by Dave Anderson
parent 853abf8661
commit e71e95b841
2 changed files with 5 additions and 1 deletions

View File

@ -173,6 +173,10 @@ func (b *Bus) dest(t reflect.Type) []*subscribeState {
}
func (b *Bus) shouldPublish(t reflect.Type) bool {
if b.routeDebug.active() {
return true
}
b.topicsMu.Lock()
defer b.topicsMu.Unlock()
return len(b.topics[t]) > 0

View File

@ -93,7 +93,7 @@ func (c *Client) publish() chan<- PublishedEvent {
}
func (c *Client) shouldPublish(t reflect.Type) bool {
return c.bus.shouldPublish(t)
return c.publishDebug.active() || c.bus.shouldPublish(t)
}
// Subscribe requests delivery of events of type T through the given