Project

General

Profile

Actions

Bug #7183

closed

Resolv::DNS::getresources throws Errno::EACCES: Permission denied - bind(2) on solaris

Added by frank_meier (Frank Meier) over 11 years ago. Updated about 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.2p180 (2011-02-18 revision 30909) [i386-solaris2.10]
Backport:
[ruby-core:48064]

Description

we have ruby running on Solaris. sometimes one of our tools fails with exception Errno::EACCES while calling Resolv::DNS::getresources. This only happens one out of thousands of times the tool is used.
After looking into lib/resolv.rb I saw, there is an optimistic loop in bind_random_port(), which looks to me it is thought of the possibility that a unusable port is selected (one that is used by another process), and if that happens it is tried again. Unfortunately it is only done when the exception is Errno::EADDRINUSE, what might be correct in Linux, but not Solaris (Sol10u6).

I propose to add Errno::EACCESS to the raise statement. Maybe a retry count limit as well:

def self.bind_random_port(udpsock, bind_host="0.0.0.0") # :nodoc:
  begin
    count += 1
    port = rangerand(1024..65535)
    udpsock.bind(bind_host, port)
  rescue Errno::EADDRINUSE, Errno::EACCESS => e
    if count < 10
      retry
    else
      raise e
    end
  end
end
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0