Skip to content

Fix pending request cleanup and improve IO fairness#107

Open
anaslimem wants to merge 1 commit intoagentclientprotocol:mainfrom
anaslimem:pending-request-cleanup
Open

Fix pending request cleanup and improve IO fairness#107
anaslimem wants to merge 1 commit intoagentclientprotocol:mainfrom
anaslimem:pending-request-cleanup

Conversation

@anaslimem
Copy link
Copy Markdown
Contributor

Summary
This PR fixes a pending-response leak and improves IO fairness in the RPC layer. It introduces a PendingRequest future that cleans up on drop, switches from biased to unbiased select in the IO loop, and adds a targeted edge-case test to verify cleanup behavior. A small test-only accessor was added to support the new test.

Changes

  • Added PendingRequest future with Drop cleanup to prevent pending_responses from growing when requests are canceled or dropped.
  • Replaced select_biased! with futures::select! in the IO loop to avoid incoming starvation under heavy outgoing traffic.
  • Downgraded “unknown response id” log to debug since dropped requests are now expected.
  • Added test_pending_response_cleanup_on_drop to validate cleanup.
  • Added a test-only pending_response_count() accessor.

Why

  • Long‑lived connections could leak memory if a caller dropped request futures or a peer never responded.
  • Biased selection could starve incoming reads under sustained outgoing load, delaying responses and exacerbating pending buildup.

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.

1 participant