1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

socket: avoid common exceptions when calling connect_nonblock

Errno::EISCONN and IO::WaitReadable exceptions are common,
expensive, and noisy under normal use.  Avoid raising on them
since they are not exceptional.

* ext/socket/lib/socket.rb (connect_internal): avoid common exceptions
  from connect_nonblock. [ruby-core:68909]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2015-04-20 20:46:08 +00:00
parent b38a8d287c
commit 46acbe9ddd
2 changed files with 10 additions and 8 deletions

View file

@ -1,3 +1,8 @@
Tue Apr 21 05:31:00 2015 Eric Wong <e@80x24.org>
* ext/socket/lib/socket.rb (connect_internal): avoid common exceptions
from connect_nonblock. [ruby-core:68909]
Mon Apr 20 23:46:53 2015 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_wreadlink): follow the official format of

View file

@ -50,17 +50,14 @@ class Addrinfo
sock.ipv6only! if self.ipv6?
sock.bind local_addrinfo if local_addrinfo
if timeout
begin
sock.connect_nonblock(self)
rescue IO::WaitWritable
case sock.connect_nonblock(self, exception: false)
when 0 # success or EISCONN, other errors raise
break
when :wait_writable
if !IO.select(nil, [sock], nil, timeout)
raise Errno::ETIMEDOUT, 'user specified timeout'
end
begin
sock.connect_nonblock(self) # check connection failure
rescue Errno::EISCONN
end
end
end while true
else
sock.connect(self)
end