From: "osyoyu (Daisuke Aritomo) via ruby-core" Date: 2025-12-05T13:59:16+00:00 Subject: [ruby-core:124040] [Ruby Feature#12928] Use socket conect_timeout in net stdlib for open_timeout Issue #12928 has been updated by osyoyu (Daisuke Aritomo). For the record: net/http now uses `TCPSocket.open(open_timeout:)` in place of `Timeout.timeout`. https://github.com/ruby/net-http/pull/224 ---------------------------------------- Feature #12928: Use socket conect_timeout in net stdlib for open_timeout https://bugs.ruby-lang.org/issues/12928#change-115471 * Author: xiewenwei (xie wenwei) * Status: Open ---------------------------------------- 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]] -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/