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)
This commit is contained in:
@@ -230,8 +230,16 @@ func TestAProofIsAskedAndAnsweredAndNeverKept(t *testing.T) {
|
||||
}
|
||||
}
|
||||
// 721/AC4: at its stop the runner takes its proofs' subscriptions down with the rest (design 47 H2 H-A-570 (1)): a proof
|
||||
// after it meets no responders, never an answer of the old runner's, and a proof answered after it is not subscribed.
|
||||
conn.StopAnswering()
|
||||
// after it meets no responders, never an answer of the old runner's, and a proof answered after it is not subscribed. The
|
||||
// stop begins here while a second answerer of the proofs subscribes, between its subscription and its keeping: that one
|
||||
// is taken down and refused too.
|
||||
var once sync.Once
|
||||
bus.SetSubscribedHook(conn, func(string) { once.Do(conn.StopAnswering) })
|
||||
if _, err := conn.SeatAnswer("messenger", "mesh.seat.intake.proof.code.*", func(string, json.RawMessage) (json.RawMessage, error) {
|
||||
return json.RawMessage(`{"raced":true}`), nil
|
||||
}); err == nil {
|
||||
t.Error("a proof answerer that raced the stop was kept, want it refused")
|
||||
}
|
||||
if raw, err := conn.SeatProve("telegram", "mesh.seat.intake.proof.code.telegram", json.RawMessage(`{"code":"123456"}`)); err == nil ||
|
||||
!strings.Contains(err.Error(), "nothing answers") {
|
||||
t.Errorf("a proof after the stop was answered %s, %v; want no responders", raw, err)
|
||||
|
||||
Reference in New Issue
Block a user