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

File descriptor not closed in TimerFd #1379

Closed
crdumoul opened this issue Jan 29, 2021 · 2 comments
Closed

File descriptor not closed in TimerFd #1379

crdumoul opened this issue Jan 29, 2021 · 2 comments

Comments

@crdumoul
Copy link

As specified in https://man7.org/linux/man-pages/man2/timerfd_create.2.html the file descriptor for a timerfd should be closed when it is no longer required. In nix::sys::timerfd::TimerFd there is no Drop implementation and the file descriptor is not automatically closed. This leads to a file descriptor leak.

The TimerFd struct either needs to properly own the file descriptor and close it when it's dropped, or make it explicit through documentation that the user of TimerFd needs to close the file descriptor themselves.

@asomers
Copy link
Member

asomers commented Jan 31, 2021

Good catch! Would you be willing to submit a PR to fix it?

@crdumoul
Copy link
Author

crdumoul commented Feb 1, 2021

I'll do that shortly.

bors bot added a commit that referenced this issue Feb 20, 2021
1381: Close file descriptor on drop in TimerFd r=asomers a=crdumoul

This change closes the TimerFd file descriptor on drop. Note that the TimerFd will no longer be `Clone` or `Copy`. Since it has a destructor it can't be `Copy`, and if it were `Clone` you could end up trying to use a closed TimerFd, or double-closing the file descriptor.

Addresses #1379.

Co-authored-by: Christopher Dumoulin <cdumouli@akamai.com>
Co-authored-by: Alan Somers <asomers@gmail.com>
@asomers asomers closed this as completed Mar 21, 2021
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

No branches or pull requests

2 participants