Closed zeenix closed 1 year ago
In GitLab by @elmarco on Oct 26, 2021, 10:55
Hi @wezm, by default zbus will keep ownership of returned message FDs.
There are a few ways this can be solved (to avoid extra dup()
if necessary), but the most straightforward is to return an OwnedFd
, and call into_raw_fd()
. We should probably update xmlgen to return OwnedFd
by default.
In GitLab by @wezm on Oct 26, 2021, 12:51
Ahh thank you. I had actually tried OwnedFd
previously and still had issues. into_raw_fd
vs. as_raw_fd
was the bit I was missing. Feel free to close this issue.
Update: I am curious about this if you can spare the time, but it's certainly not super important:
There are a few ways this can be solved (to avoid extra
dup()
if necessary)
We should probably update xmlgen to return
OwnedFd
by default.
This part was taken care of by !412. So close this.
In GitLab by @wezm on Oct 26, 2021, 24:48
zbus version: 2.0.0-beta.7
Rust version: rustc 1.56.0 (09c42c458 2021-10-18)
Kernel version: 5.14.12-arch1-1
D-Bus version: 1.12.20-1
Udisks2 version: 2.9.4-1
I'm using zbus to talk to UDisks2. I used zbus_xmlgen to generate a proxy for the Block interface. I'm calling the OpenDevice method and getting back an fd, however attempting to use the fd always gives a Bad file descriptor error. In
strace
I can see that it appears to be closed immediately.I saw the note on Message but I'm not sure how to do that with a generated proxy.
My code:
The generated proxy:
strace
, noteclose(8)
immediately beforestatx(8)
and generation of the error message: