dRuby服务器在侦听的端口上进行探测时崩溃

时间:2013-03-06 19:47:59

标签: ruby jruby drb

我有这个测试代码:

require 'drb/drb'

DRb.start_service(nil, "hello")
puts DRb.uri
DRb.thread.join()

如果我然后使用类似nmap的东西探测它抓取的端口,经过一些探测后,应用程序崩溃了。

在JRuby 1.7下,我得到了这个堆栈:

Errno::ENOPROTOOPT: Protocol not available - Protocol not available
   setsockopt at org/jruby/ext/socket/RubyBasicSocket.java:294
  set_sockopt at /Users/kimptoc/.rvm/rubies/jruby-1.7.3/lib/ruby/1.9/drb/drb.rb:1005
   initialize at /Users/kimptoc/.rvm/rubies/jruby-1.7.3/lib/ruby/1.9/drb/drb.rb:927
       accept at /Users/kimptoc/.rvm/rubies/jruby-1.7.3/lib/ruby/1.9/drb/drb.rb:991
    main_loop at /Users/kimptoc/.rvm/rubies/jruby-1.7.3/lib/ruby/1.9/drb/drb.rb:1615
          run at /Users/kimptoc/.rvm/rubies/jruby-1.7.3/lib/ruby/1.9/drb/drb.rb:1465

在Ruby 1.9.3-392下,堆栈是这样的:

/Users/kimptoc/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/drb/drb.rb:964:in `setsockopt': Invalid argument (Errno::EINVAL)
from /Users/kimptoc/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/drb/drb.rb:964:in `set_sockopt'
from /Users/kimptoc/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/drb/drb.rb:886:in `initialize'
from /Users/kimptoc/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/drb/drb.rb:950:in `new'
from /Users/kimptoc/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/drb/drb.rb:950:in `accept'
from /Users/kimptoc/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/drb/drb.rb:1574:in `main_loop'
from /Users/kimptoc/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/drb/drb.rb:1424:in `block in run'

有没有办法让dRuby更健壮(例如某个选项或配置设置),并且在这些情况下不会崩溃。

更新

通过将代码置于这样的循环中,这似乎使其更具弹性 - 但这是最​​好的前进方式:

while true
  begin
    DRb.start_service("druby://localhost:12345", "hello")
    puts DRb.uri
    DRb.thread.join()
  rescue Exception => e
    puts e.message
  end
end

TIA

0 个答案:

没有答案