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

BasicSocket#getsockopt does not work with all possible Symbol combinations #3438

Closed
YorickPeterse opened this Issue Oct 30, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@YorickPeterse

YorickPeterse commented Oct 30, 2015

The spec at https://github.com/rubysl/rubysl-socket/blob/3950231ce2af8a438deeaa6006fd177356149823/spec/basicsocket/getsockopt_spec.rb currently fails with the following output found at https://gist.github.com/YorickPeterse/d98ec87d068f7237220e

Looking at

protected static SocketOption optionFromArg(IRubyObject _opt) {
SocketOption opt;
if (_opt instanceof RubyString || _opt instanceof RubySymbol) {
opt = SocketOption.valueOf("SO_" + _opt.toString());
} else {
opt = SocketOption.valueOf(RubyNumeric.fix2int(_opt));
}
return opt;
}
protected static SocketLevel levelFromArg(IRubyObject _level) {
SocketLevel level;
if (_level instanceof RubyString || _level instanceof RubySymbol) {
level = SocketLevel.valueOf("SOL_" + _level.toString());
} else {
level = SocketLevel.valueOf(RubyNumeric.fix2int(_level));
}
return level;
}
it seems JRuby assumes the level/optname prefixes are always SOL_/SO_ instead of basing the prefix on the level.

For Rubinius we use the following code to determine the prefixes: https://github.com/rubysl/rubysl-socket/blob/ff68150719df6bedc72ec159fc2e5f166851e800/lib/rubysl/socket/socket_options.rb#L4-L49

@YorickPeterse

This comment has been minimized.

Show comment
Hide comment
@YorickPeterse

YorickPeterse Oct 30, 2015

Looking at the spec output it also seems JRuby doesn't implement everything of Socket::Option, e.g. the bool and linger methods.

YorickPeterse commented Oct 30, 2015

Looking at the spec output it also seems JRuby doesn't implement everything of Socket::Option, e.g. the bool and linger methods.

@headius

This comment has been minimized.

Show comment
Hide comment
@headius

headius Oct 30, 2015

Member

Yes, this is known. We do not use FFI to implement socket and are limited in how many options the JDK Socket classes support.

Member

headius commented Oct 30, 2015

Yes, this is known. We do not use FFI to implement socket and are limited in how many options the JDK Socket classes support.

etehtsea added a commit to etehtsea/jruby that referenced this issue Aug 31, 2016

Fix passing socket option in a form of SO_OPTION
For example:
Socket::Option.new(:UNSPEC, :SOCKET, :SO_LINGER, [0, 0].pack('i*')
Fixes #3438

etehtsea added a commit to etehtsea/jruby that referenced this issue Aug 31, 2016

Fix passing socket level in a form of SOL_LEVEL
For example:
Socket::Option.int(:AF_UNSPEC, :SOL_SOCKET, :LINGER, 1)
Fixes #3438

etehtsea added a commit to etehtsea/jruby that referenced this issue Sep 7, 2016

Fix passing socket option in a form of SO_OPTION
For example:
Socket::Option.new(:UNSPEC, :SOCKET, :SO_LINGER, [0, 0].pack('i*')
Fixes #3438

etehtsea added a commit to etehtsea/jruby that referenced this issue Sep 7, 2016

Fix passing socket level in a form of SOL_LEVEL
For example:
Socket::Option.int(:AF_UNSPEC, :SOL_SOCKET, :LINGER, 1)
Fixes #3438

etehtsea added a commit to etehtsea/jruby that referenced this issue Sep 8, 2016

Fix passing socket level in a form of SOL_LEVEL
For example:
Socket::Option.int(:AF_UNSPEC, :SOL_SOCKET, :LINGER, 1)
Fixes #3438

etehtsea added a commit to etehtsea/jruby that referenced this issue Sep 12, 2016

Fix passing socket option in a form of SO_OPTION
For example:
Socket::Option.new(:UNSPEC, :SOCKET, :SO_LINGER, [0, 0].pack('i*')
Fixes #3438

etehtsea added a commit to etehtsea/jruby that referenced this issue Sep 12, 2016

Fix passing socket level in a form of SOL_LEVEL
For example:
Socket::Option.int(:AF_UNSPEC, :SOL_SOCKET, :LINGER, 1)
Fixes #3438

@headius headius closed this in a87d873 Sep 12, 2016

@enebo enebo added this to the JRuby 9.1.6.0 milestone Nov 9, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment