Skip to content

connection: share handshake ack parsing and account merge - #959

Open
tradatious wants to merge 1 commit into
wboayue:mainfrom
tradatious:handshake-shared-parts
Open

tradatious wants to merge 1 commit into
wboayue:mainfrom
tradatious:handshake-shared-parts

Conversation

@tradatious

@tradatious tradatious commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

The blocking and async connections each had their own copy of two parts of the startup handshake
that do not depend on the runtime:

  • turning the handshake reply into the server version, connection time and time zone, including
    mapping a reply that ends in UnexpectedEof to Error::ConnectionRejected;
  • merging the account-info frames received at startup and copying the result into
    ConnectionMetadata.

Both now live in connection::common as parse_handshake_ack, AccountInfo::merge and
ConnectionMetadata::apply_account_info, and MAX_ACCOUNT_INFO_ATTEMPTS replaces the two local
MAX_ATTEMPTS constants. Each connection calls them and keeps only its own I/O and locking.

One ordering difference, on both clients: the reply is parsed before the metadata lock is taken,
where it used to be parsed while holding it (on the blocking client a bad reply is therefore
reported ahead of a poisoned lock). Nothing else changes.

Testing

New tests in connection/common_tests.rs: test_parse_handshake_ack (a valid reply, an
UnexpectedEof reply, another I/O error), test_account_info_merge and
test_connection_metadata_apply_account_info. The existing sync and async handshake tests pass
unchanged. cargo fmt --check; clippy, rustdoc (-D warnings) and cargo test on all three feature
configurations; cargo build --examples both ways; integration crates built.

Breaking changes

No. Crate-internal.

parse_handshake_ack, AccountInfo::merge and
ConnectionMetadata::apply_account_info move the runtime-free parts of
the sync and async handshakes into connection::common. No behaviour
change.
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