-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Pass fd
implicitly to System::FileDescriptor
and System::Socket
#16137
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
Pass fd
implicitly to System::FileDescriptor
and System::Socket
#16137
Conversation
On UNIX also delegates the implementation from `System::Socket` to `System::FileDescriptor` since it's identical.
Instead use class methods on System::Socket on Win32 for the one case where we need to configure the socket handle after accept.
Crystal::System::Socket.fcntl(fd, cmd, arg) | ||
end | ||
|
||
def fcntl(cmd, arg = 0) |
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.
The Socket#fcntl
and Socket.fcntl
methods aren't portable, rely on LibC constants to call. We might want to consider deprecating 'em?
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.
Let's consider that in a follow up PR then.
I'm missing a change to |
…6137] (#16183) I missed a couple cases in #16137 in preparation of #16127 where we need a system indirection around the `fd`, so #16128 will be able to count a reference: - `Crystal::System::File#system_chown` - `Crystal::System::Socket#system_accept` Note that by itself the change has no impact or interest.
Extracts the refactors out of #16128.
The main point is to not pass
fd
explicitly as an argument and to instead letSystem::FileDescriptor
andSystem::Socket
use thefd
property. This allows #16128 to wrap calls affecting thefd
to wrap them in a reference counter.See each individual commit for details on each change.