Skip to content

fix(translator): eagerly mark_closed on malformed-JSON disconnect (#241) - #281

Open
ANAMASGARD wants to merge 1 commit into
dmnd-pool:masterfrom
ANAMASGARD:fix/malformed-json-teardown-241
Open

fix(translator): eagerly mark_closed on malformed-JSON disconnect (#241)#281
ANAMASGARD wants to merge 1 commit into
dmnd-pool:masterfrom
ANAMASGARD:fix/malformed-json-teardown-241

Conversation

@ANAMASGARD

Copy link
Copy Markdown

Summary

  • Eagerly call mark_closed() at the malformed-JSON break site in the SV1 downstream receive loop so deferred bootstrap tasks cannot observe is_closed == false for a connection that is already dead.
  • Add regression tests proving invalid JSON-RPC input triggers full teardown: closed flag, stats removal, and task-manager kill signal (bootstrap abort).
  • Add a sequential deferred-bootstrap test ensuring closed downstreams do not re-register stats or enqueue mining.notify.

Fixes #241

Context

Malformed JSON previously used return inside the receive task, which skipped post-loop teardown (mark_closed, stats cleanup, kill signal). That was fixed to break in 0076242, and notify/bootstrap guards were added in d1c3fb3. This PR closes the remaining race window between break and post-loop mark_closed(), and locks the behavior in with tests.

Changes

File Change
src/translator/downstream/receive_from_downstream.rs Eager mark_closed() on malformed JSON + 2 regression tests

No changes to downstream.rs, notify.rs, or bootstrap registration.

Test plan

  • cargo test malformed_json — 2 new tests pass
    • malformed_json_triggers_full_teardown
    • malformed_json_races_deferred_bootstrap
  • cargo test receive_from_downstream
  • cargo test — full suite green
  • cargo clippy -- -D warnings (CI)
  • cargo fmt --check (CI)

Closes dmnd-pool#241
Before this commit, mark_closed() only ran after the receive loop
exited. A deferred bootstrap task reading is_closed() between the
break and the post-loop teardown could observe a live session for
an already-dead connection. Add eager mark_closed() at the
malformed-JSON break site and regression tests that assert full
teardown (closed flag, stats removal, kill signal) on invalid input.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix malformed json handling

1 participant