Skip to content

Implement Addrinfo.getaddrinfo #1377

@sferik

Description

@sferik

If you look at Travis CI build 183 of the tarcieri/http repo, you’ll see that it passes on every major CRuby version (1.8.7 through 2.1.0), Rubinius 2, and JRuby 1.7.9 (in both Ruby 1.8 and Ruby 1.9 modes).

However, it fails on JRuby 9K. Here is the full version description:

jruby 9000.dev (2.1.0.dev) 2013-12-27 c66a441 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_45-b18 [linux-amd64]

Specifically, the test suite errors out whilst starting WEBrick, raising the following exception. I have snipped just the relevant portion of the stack trace:

NoMethodError: undefined method `each' for nil:NilClass
             foreach at /home/travis/.rvm/rubies/jruby-head/lib/ruby/2.1/socket.rb:217
  tcp_server_sockets at /home/travis/.rvm/rubies/jruby-head/lib/ruby/2.1/socket.rb:441
    create_listeners at /home/travis/.rvm/rubies/jruby-head/lib/ruby/2.1/webrick/utils.rb:75
              listen at /home/travis/.rvm/rubies/jruby-head/lib/ruby/2.1/webrick/server.rb:132
          initialize at /home/travis/.rvm/rubies/jruby-head/lib/ruby/2.1/webrick/server.rb:113
          initialize at /home/travis/.rvm/rubies/jruby-head/lib/ruby/2.1/webrick/httpserver.rb:45
              (root) at /home/travis/build/tarcieri/http/spec/support/example_server.rb:75

The error originates with this seemingly innocuous line of code:

ExampleServer = WEBrick::HTTPServer.new(:Port => ExampleService::PORT, :AccessLog => [])

Here is the full source code of that file at the current snapshot in time.

Before reporting this issue, I chatted with @enebo on IRC. He suggested that this failure was related to the fact that Addrinfo::getaddrinfo is not yet implemented.

public static IRubyObject getaddrinfo(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
    // unimplemented
    return context.nil;
}

According to @enebo:

no doubt someone can impl this but it is 666 lines of code in MRI for getaddrinfo…looks like although Java net APIs cannot do this stuff, it can be done through jnr-posix and friends or perhaps even an FFI impl

Unfortunately, I am highly unqualified to even begin working on this myself but I wish you the best of luck with the implementation. 🙏🍀


The rspec command also outputs the following warnings, which seem to be unrelated, but I thought would be worth reporting anyway:

/home/travis/.rvm/rubies/jruby-head/lib/ruby/shared/krypt/hmac.rb:54 warning: shadowing outer local variable - new_key
/home/travis/.rvm/rubies/jruby-head/lib/ruby/shared/krypt/codec/hex.rb:65 warning: shadowing outer local variable - data
/home/travis/.rvm/rubies/jruby-head/lib/ruby/shared/krypt/codec/hex.rb:112 warning: shadowing outer local variable - data
/home/travis/.rvm/rubies/jruby-head/lib/ruby/shared/krypt/codec/base64.rb:78 warning: shadowing outer local variable - data
/home/travis/.rvm/rubies/jruby-head/lib/ruby/shared/krypt/codec/base64.rb:130 warning: shadowing outer local variable - data

These warnings also occur on JRuby 1.7.9 in Ruby 1.9 mode, where the build is passing, which is why I believe they are unrelated. Note: they do not occur on JRuby 1.7.9 in Ruby 1.8 mode.

/cc @tarcieri

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions