-
Notifications
You must be signed in to change notification settings - Fork 82
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
How to close the file description when a method return it ? #95
Comments
It should be closed by the recipient of the file descriptor (the caller?). I believe there are examples of using the file descriptor calls in bmcweb. Do you have examples of failing code? |
checked bmcweb, seems it just send file description as method param, but not a return value |
https://github.com/openbmc/bmcweb/blob/de0c960c4262169ea92a4b852dd5ebbe3810bf00/redfish-core/lib/log_services.hpp#L863 I'm not sure how it works, but in this code it seems like the |
When I did some code for a method that returned an FD with the sdbusplus bindings a few years ago, I think I remember that the FDs would leak if you didn't do anything, so I put in a sd_io_event_add_defer to close the file descriptor when the code got back to the event loop and that worked. |
@spinler Any idea why you couldn't close it at the consumption location? |
In the client? That's a dup'ed descriptor so the original in the server remained open. |
For the server, I would expect:
For the client, I would expect:
I don't really understand why the |
I find a funny thing, I open a file, and set the fd as param to call a service method, while the servie handle the method call, I can see a new fd in /proc/xxx/fd for the service, after the method return, the caller close the fd, then I find the fd in for service /proc/xxx/fd also disapper |
If a method of a service return a file description to the caller, where and how to close the file description ?
I have a try to close it in caller, it will a coredump in caller.
If have to close it in service, how ?
The text was updated successfully, but these errors were encountered: