-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Let Crystal::EventLoop#close
do the actual close (not just cleanup)
#15641
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
base: master
Are you sure you want to change the base?
Let Crystal::EventLoop#close
do the actual close (not just cleanup)
#15641
Conversation
Internal refactor to have the `Crystal::EventLoop#close(io)` implementations be responsible from actually closing the file descriptor or socket, not only do some internal cleanup before closing. This will allow the io_uring event loop to close asynchronously for example.
@@ -131,7 +126,7 @@ module Crystal::System::FileDescriptor | |||
|
|||
# Clear the @volatile_fd before actually closing it in order to | |||
# reduce the chance of reading an outdated fd value | |||
_fd = @volatile_fd.swap(-1) | |||
return unless _fd = close_volatile_fd? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variables marked with leading underscore are conventionally treated as unused, also there's no need to do that here, why not just drop it?
ditto elsewhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea why it was used in the first place, maybe to convey the difference with the #fd
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's pretty common to shadow the instance variables / getters, though that's a minor suggestion overall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should just use fd
because we just poisoned @volatile_fd
so #fd
is invalid now anyway.
Internal refactor to have the
Crystal::EventLoop#close(io)
implementations be responsible from actually closing the file descriptor or socket, not only do some internal cleanup before closing. They now follow the abstract methods documentation:This will allow the io_uring event loop to close asynchronously.
Exposes the
#close_volatile_fd?
helper on UNIX that will prove helpful in io_uring.Follow-up to #15640
Extracted from #15634