Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡️ zb: Pipeline client-side handshake as much as possible #683

Merged
merged 7 commits into from
Mar 25, 2024

Conversation

zeenix
Copy link
Contributor

@zeenix zeenix commented Mar 21, 2024

We now send DATA, NEGOTIATE_UNIX_FD and BEGIN commands at once. This reduces latency and hence improves performance.

It would have been the best to send all the commands at the same time, but seems dbus-daemon kick us out if we send multiple commands after it rejects the auth command. It wants us to negotiate the auth first. We could in theory just reconnect but that would require some architectural changes and rethinking the code.

Moreover cookie auth requires a round-trip to the server to get the cookie context first so we can't fully pipeline that one.

The server side is not possible to pipeline as it the server just responds to commands from the client and it can not assume that clients will always pipeline all commands.

Fixes #493.

@zeenix zeenix force-pushed the pipeline-handshake branch 2 times, most recently from 80fcf3f to 4d1bcef Compare March 22, 2024 11:36
@zeenix zeenix marked this pull request as draft March 22, 2024 11:58
@zeenix
Copy link
Contributor Author

zeenix commented Mar 22, 2024

@kas (I assume you're this guy) Hi there, seems the gdbus doesn't really correctly do handshake and pipelining handshake breaks there. While I was more than happy to add the support for that but if supporting the special gdbus session bus means we don't get to do smart things in zbus, I'd rather remove the support (or be OK with it being broken until gdbus is fixed).

@zeenix zeenix force-pushed the pipeline-handshake branch 2 times, most recently from d8757f5 to 48e3cae Compare March 22, 2024 15:11
@zeenix zeenix force-pushed the pipeline-handshake branch from 48e3cae to ce2e5ab Compare March 22, 2024 16:00
@zeenix
Copy link
Contributor Author

zeenix commented Mar 22, 2024

@kas (I assume you're this guy) Hi there, seems the gdbus doesn't really correctly do handshake and pipelining handshake breaks there.

Oh never mind. The issue seems reproducible with dbus-daemon as well. I need to make the pipelining be able handle disconnection from the server, as well.

@zeenix zeenix force-pushed the pipeline-handshake branch 2 times, most recently from 0799845 to 9694445 Compare March 24, 2024 22:56
@zeenix zeenix changed the title ⚡️ zb: Pipeline client-side handshake ⚡️ zb: Pipeline client-side handshake as much as possible Mar 24, 2024
@zeenix zeenix force-pushed the pipeline-handshake branch from 9694445 to c9eae0d Compare March 25, 2024 10:12
@zeenix zeenix marked this pull request as ready for review March 25, 2024 10:13
@zeenix zeenix marked this pull request as draft March 25, 2024 11:11
@zeenix zeenix force-pushed the pipeline-handshake branch 4 times, most recently from 3fe0618 to 25307e6 Compare March 25, 2024 13:05
@zeenix
Copy link
Contributor Author

zeenix commented Mar 25, 2024

Seems I was right about GDBus being unable to handle pipelining. It requires BEGIN command to be sent separately after client receive OK on the authentication. Fortunately, the workaround is not too dirty.

zeenix added 5 commits March 25, 2024 14:23
We now send `DATA`, `NEGOTIATE_UNIX_FD` and `BEGIN` commands at once. This
reduces latency and hence improves performance.

It would have been the best to send all the commands at the same time,
but seems dbus-daemon kick us out if we send multiple commands after it
rejects the auth command. It wants us to negotiate the auth first. We
could in theory just reconnect but that would require some achitectural
changes and rethinking the code.

Moreover cookie auth requires a round-trip to the server to get
the cookie context first so we can't fully pipeline that one.

Furthermore, gdbus is not able to handle `BEGIN` sent along with `DATA`,
so we have to send `BEGIN` separately when gdbus feature is enabled on
Windows.

The server side is not possible to pipeline as it the server just
responds to commands from the client and it can not assume that clients
will always pipeline all commands.

Fixes dbus2#493.
Otherwise it messes up the logging output.
If a received command from the client is unknown or invalid in the
current context, we shouldn't completely error out but rather send an
error and continue as if nothing happened.
If the client sends a `CANCEL` command during a handshake, the server
must move on to the handshake method available (if any). The exact
wording in the spec:

> On receiving the CANCEL command, the server must send a REJECTED
> command and abort the current authentication exchange.
@zeenix zeenix force-pushed the pipeline-handshake branch from 25307e6 to 73797b7 Compare March 25, 2024 13:23
@zeenix zeenix marked this pull request as ready for review March 25, 2024 13:23
@zeenix zeenix enabled auto-merge March 25, 2024 13:23
@zeenix zeenix merged commit 1311d29 into dbus2:main Mar 25, 2024
5 checks passed
@zeenix zeenix deleted the pipeline-handshake branch March 25, 2024 13:29
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.

Pipeline handshakes
1 participant