Files
mesh-tools/node-tools/internal/bus/export_test.go
T
jschoubben 5d87f7d375 node-tools: a serve racing the runner's stop is taken down too (issue 721, review round 1)
A tool's or a proof's subscription made while the stop took its snapshot was registered
after it, so it stayed subscribed until the close and its callers waited out their bound
instead of meeting no responders (the review's probe: 4 of 2000 rounds). Now a new
answering subscription is kept, and the stop checked again, in one section under the lock
the stop takes its subscriptions down under; when the stop began meanwhile, it is drained
and the serve refused.

Tests: 721/AC4 rows in the bus (a tool's serve and a proof answerer each run the stop
between their subscription and its keeping, through a test hook, and are refused; their
callers meet no responders), failing without the locked check.

Builds: design 47 H2 H-A-570 (1)
2026-11-23 16:51:00 +01:00

17 lines
538 B
Go

package bus
// SetTickHook makes the next consumes call f after each idle heartbeat interval was handled; the restore puts it back.
func SetTickHook(f func()) (restore func()) {
old := tickHook
tickHook = f
return func() { tickHook = old }
}
// SetSubscribedHook makes c call f with the subject between making each answering subscription and keeping it, so a test can
// run the stop in between (design 47 H2 H-A-570 (1)).
func SetSubscribedHook(c *Conn, f func(subject string)) {
c.mu.Lock()
c.subscribedHook = f
c.mu.Unlock()
}