Forum: Ruby-core [ruby-trunk - Bug #7183][Open] Resolv::DNS::getresources throws Errno::EACCES: Permission denied - b

Posted by frank_meier (Frank Meier) (Guest)
on 2012-10-18 14:47
(Received via mailing list)
Issue #7183 has been reported by frank_meier (Frank Meier).

----------------------------------------
Bug #7183: Resolv::DNS::getresources throws Errno::EACCES: Permission 
denied - bind(2) on solaris
https://bugs.ruby-lang.org/issues/7183

Author: frank_meier (Frank Meier)
Status: Open
Priority: Normal
Assignee:
Category:
Target version: 1.9.3
ruby -v: ruby 1.9.2p180 (2011-02-18 revision 30909) [i386-solaris2.10]


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
Posted by mame (Yusuke Endoh) (Guest)
on 2012-11-05 13:52
(Received via mailing list)
Issue #7183 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee set to akr (Akira Tanaka)
Target version changed from 1.9.3 to 2.0.0

Akr-san, could you check this?

--
Yusuke Endoh <mame@tsg.ne.jp>
----------------------------------------
Bug #7183: Resolv::DNS::getresources throws Errno::EACCES: Permission 
denied - bind(2) on solaris
https://bugs.ruby-lang.org/issues/7183#change-32408

Author: frank_meier (Frank Meier)
Status: Assigned
Priority: Normal
Assignee: akr (Akira Tanaka)
Category:
Target version: 2.0.0
ruby -v: ruby 1.9.2p180 (2011-02-18 revision 30909) [i386-solaris2.10]


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
Posted by mame (Yusuke Endoh) (Guest)
on 2013-02-18 16:14
(Received via mailing list)
Issue #7183 has been updated by mame (Yusuke Endoh).

Target version changed from 2.0.0 to next minor


----------------------------------------
Bug #7183: Resolv::DNS::getresources throws Errno::EACCES: Permission 
denied - bind(2) on solaris
https://bugs.ruby-lang.org/issues/7183#change-36539

Author: frank_meier (Frank Meier)
Status: Assigned
Priority: Normal
Assignee: akr (Akira Tanaka)
Category:
Target version: next minor
ruby -v: ruby 1.9.2p180 (2011-02-18 revision 30909) [i386-solaris2.10]


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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.