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

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

Closed
yorickpeterse opened this issue Oct 30, 2015 · 2 comments
Milestone

Comments

@yorickpeterse
Copy link

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
Copy link
Author

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

@headius
Copy link
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
For example:
Socket::Option.new(:UNSPEC, :SOCKET, :SO_LINGER, [0, 0].pack('i*')
Fixes jruby#3438
etehtsea added a commit to etehtsea/jruby that referenced this issue Aug 31, 2016
For example:
Socket::Option.int(:AF_UNSPEC, :SOL_SOCKET, :LINGER, 1)
Fixes jruby#3438
etehtsea added a commit to etehtsea/jruby that referenced this issue Sep 7, 2016
For example:
Socket::Option.new(:UNSPEC, :SOCKET, :SO_LINGER, [0, 0].pack('i*')
Fixes jruby#3438
etehtsea added a commit to etehtsea/jruby that referenced this issue Sep 7, 2016
For example:
Socket::Option.int(:AF_UNSPEC, :SOL_SOCKET, :LINGER, 1)
Fixes jruby#3438
etehtsea added a commit to etehtsea/jruby that referenced this issue Sep 8, 2016
For example:
Socket::Option.int(:AF_UNSPEC, :SOL_SOCKET, :LINGER, 1)
Fixes jruby#3438
etehtsea added a commit to etehtsea/jruby that referenced this issue Sep 12, 2016
For example:
Socket::Option.new(:UNSPEC, :SOCKET, :SO_LINGER, [0, 0].pack('i*')
Fixes jruby#3438
etehtsea added a commit to etehtsea/jruby that referenced this issue Sep 12, 2016
For example:
Socket::Option.int(:AF_UNSPEC, :SOL_SOCKET, :LINGER, 1)
Fixes jruby#3438
@enebo enebo added this to the JRuby 9.1.6.0 milestone Nov 9, 2016
seangoedecke added a commit to seangoedecke/puma that referenced this issue May 19, 2021
JRuby (at least this version) doesn't support basic Socket constants or
methods

Ref: jruby/jruby#3438
nateberkopec pushed a commit to puma/puma that referenced this issue May 20, 2021
* Treat low_latency=false as false instead of true

Previously the binder.parse code was just checking that the low_latency
key existed, but the docs (and other options) support passing options in
the format `option=false`. This commit now treats `low_latency=false` as
false, while still treating `low_latency` with no `=` as true

* Update docs to reflect code behaviour

* Skip getsockopt tests in JRuby

JRuby (at least this version) doesn't support basic Socket constants or
methods

Ref: jruby/jruby#3438
JuanitoFatas pushed a commit to JuanitoFatas/puma that referenced this issue Sep 9, 2022
* Treat low_latency=false as false instead of true

Previously the binder.parse code was just checking that the low_latency
key existed, but the docs (and other options) support passing options in
the format `option=false`. This commit now treats `low_latency=false` as
false, while still treating `low_latency` with no `=` as true

* Update docs to reflect code behaviour

* Skip getsockopt tests in JRuby

JRuby (at least this version) doesn't support basic Socket constants or
methods

Ref: jruby/jruby#3438
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

Successfully merging a pull request may close this issue.

3 participants