Repository navigation
transport: deliver_aliased + collapsed order/request fallback (#930) - #955
Merged
Merged
Conversation
- SenderHash (sync + async): private deliver_then primitive; deliver and deliver_aliased on top. Alias inserted under the route's read lock. - Async: drop deliver_execution (Option::take/expect workaround); with_route test-only. - Sync: send -> deliver returning Result<(), RoutedItem>; bound logic moves to Entry::deliver; store_execution_mapping removed; contains+send pairs collapsed where the miss path doesn't need the message. - Both: deliver_to_order_or_request as one or_else chain. - Sync OrderOrShared: drop always-true is_shared_response(OpenOrder) guard. - Async SharedChannels: channels_mut(); close() doc notes sync fail_all parity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #930.
Refactor of the follow-ups from the #929 review, plus the sync counterpart from the issue comment. No wire or routing behavior change; log and panic-recovery changes are listed below.
Changes
deliver_aliasedon bothSenderHashes. Privatedeliver_thendoes the single lookup;deliveranddeliver_aliasedsit on top. The execution alias is inserted under the route's read lock, closing the window where a concurrentClient::dropcould clear the maps between routing an execution and recording its alias. Lock order isself(read), thenaliases(write);executionsis never locked first.deliver_executionand itsOption::take/expect("undelivered item")removed;with_routeis test-only.send -> Result<(), Error>(alwaysOk) becomesdeliver -> Result<(), RoutedItem>; bound logic moves toEntry::deliver, mirroring asyncRoute::deliver;store_execution_mappingremoved.deliver_to_order_or_requeston each bus, oneor_elsechain, used by ExecutionData and ExecutionDataEnd. Removes the fouritem = match …blocks (async) and the duplicatedcontains+sendblocks with unreachableErrbranches (sync).OrderOrShared. Dropped theis_shared_response(IncomingMessages::OpenOrder)guard: a constant, always true since bothOpenOrderandOrderStatusare in every open-orders mapping.SharedChannels.channels_mut()next tochannels();close()doc notes it's the counterpart of syncSharedChannels::fail_all.Follow-ups (parity fixes found in review)
OrderOrShared.containscheck thendeliver, instead of cloning everyOpenOrder/OrderStatusframe to keep it for the shared fallback. Matches sync.SenderHashlock poisoning.read()/write()helpers recover from poison (PoisonError::into_inner), as async does, so one panic under the lock no longer panics every later route and teardown. Regression test included.lock_slothelper, mirroring async's. Before:send_order_update_itemandclear_order_update_streamskipped on poison (if let Ok), silently dropping updates and leaving the slot uncleanable; other sites panicked. Regression test included.Notes
Route.sender/Route.leasestaypub(super): the async order update stream is aRouteand reads both.process_response_with_idandOrderOrSharedkeep theircontainsguard: the miss path needs theResponseMessage(shared send, unroutable report), andErr(item)hands back aRoutedItem.debug!dump of the whole route map is gone, and the generic "no recipient found" warn is replaced by call-site warns.Tests
deliver_aliasedtests on both sides: alias registered with the shared lease,Nonealias registers nothing, unrouted hands the item back without aliasing.cargo test --lib,cargo clippy --all-targets -- -D warnings(default, sync, all-features),cargo fmt --check,RUSTDOCFLAGS=-D warnings cargo docall clean.