[ruby-core:68953] Re: [Ruby trunk - Feature #11081] [Open] [PATCH] stdlib: use IO#wait_*able instead of IO.select when possible

From: bhushanpant@...
Date: 2015-04-21 18:26:28 UTC
List: ruby-core #68953
Paa

Eric Wong <normalperson@yhbt.net> wrote:

>Also, this (untested) patch.  I forgot the "::" style calling convention
>when checking for IO.select callers.
>
>diff --git a/lib/net/telnet.rb b/lib/net/telnet.rb
>index 2260e7f..3c4099c 100644
>--- a/lib/net/telnet.rb
>+++ b/lib/net/telnet.rb
>@@ -11,6 +11,7 @@
> 
> require "net/protocol"
> require "English"
>+require "io/wait"
> 
> module Net
> 
>@@ -552,8 +553,8 @@ module Net
>       line = ''
>       buf = ''
>       rest = ''
>-      until(prompt === line and not IO::select([@sock], nil, nil, waittime))
>-        unless IO::select([@sock], nil, nil, time_out)
>+      until(prompt === line and not @sock.wait_readable(waittime))
>+        unless @sock.wait_readable(time_out)
>           raise Net::ReadTimeout, "timed out while waiting for more data"
>         end
>         begin
>@@ -610,7 +611,7 @@ module Net
>     def write(string)
>       length = string.length
>       while 0 < length
>-        IO::select(nil, [@sock])
>+        @sock.wait_writable
>         @dumplog.log_dump('>', string[-length..-1]) if @options.has_key?("Dump_log")
>         length -= @sock.syswrite(string[-length..-1])
>       end

In This Thread

Prev Next