Project

General

Profile

Feature #12928

Use socket conect_timeout in net stdlib for open_timeout

Added by xiewenwei (xie wenwei) over 3 years ago. Updated 6 months ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:78106]

Description

Current net/http and net/pop use Timeout.timeout to tigger open_timeout event.
Timeout.timeout is slow. It will create and destroy a thread every time.
Timeout.timeout is also dangerous. see [[[http://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/]]]

It is more effective and safe to use socket timeout to accomplish this.
Follow is the changes need to do.

  1. Replace TCPSocket.open with Socket.new
  2. Use socket.connect_nonblock and IO.select to connect and trigger timeout event.

The pull request is here:
[[[https://github.com/ruby/ruby/pull/1480]]]


Related issues

Related to Ruby master - Feature #12435: Using connect_nonblock to open TCP connections in Net::HTTP#connectOpenActions

Also available in: Atom PDF