xdg-dbus-proxy icon indicating copy to clipboard operation
xdg-dbus-proxy copied to clipboard

auth: Support sd-bus authentication pipelining

Open evan-a-a opened this issue 2 years ago • 5 comments

Since sd-dbus clients send the BEGIN before receiving OK, ensure that we look for both to come across the bus in either order.

Fixes https://github.com/flatpak/xdg-dbus-proxy/issues/21

evan-a-a avatar May 11 '23 15:05 evan-a-a

@alexlarsson or @smcv, can you take a look at this? I believe it solves the concerns present in #26. This change is important for https://github.com/flathub/com.microsoft.Edge/pull/252 and other applications that rely on sd-bus.

evan-a-a avatar May 22 '23 17:05 evan-a-a

It feels a bit lame to read a byte at a time. Thats quite a lot of syscalls... Did you look at how this affects the time spent on authentication?

Anyway, i would like @smcv to look at this too. He knows the dbus stuff best.

alexlarsson avatar May 23 '23 06:05 alexlarsson

The reading of one line a time will also cause the writing to the proxy client to be split up, so the performance is not just in the number of read calls. It will become multiple "network packets" too.

alexlarsson avatar May 23 '23 06:05 alexlarsson

It feels a bit lame to read a byte at a time. Thats quite a lot of syscalls... Did you look at how this affects the time spent on authentication? The reading of one line a time will also cause the writing to the proxy client to be split up, so the performance is not just in the number of read calls. It will become multiple "network packets" too.

I agree, it's quite lame. Handling the over-read with the extra buffer management seems to be a "less clean" option to me. I actually based this on how gdbus' server code fixes the handling of sd-bus clients. In https://github.com/GNOME/glib/commit/8f02681f6e2130c52f27c1edb4febb1443e97d94, they modified their code to only read one byte at a time, which prevents the over-read case. I didn't benchmark exactly how much this slows down the auth process, but I didn't notice any responsiveness issues in the one sd-bus client I tested. I can try to set up a test harness to collect some timing info.

evan-a-a avatar May 23 '23 13:05 evan-a-a

Actually, after looking at the reference implementation, I have a better idea about how to tackle this while avoiding the single byte reads. I will work on that improvement.

evan-a-a avatar May 23 '23 14:05 evan-a-a

A variant of this has been merged in #54

bilelmoussaoui avatar Aug 21 '24 21:08 bilelmoussaoui