From a539b011da07c6b34f0acd6166e9bfa2e6fe5f8a Mon Sep 17 00:00:00 2001 From: shugo Date: Fri, 12 May 2017 09:39:23 +0000 Subject: net/imap: Revert read_tiemout in r58549. get_response is called in a receiver thread, so there may be no pending commands when get_response is called. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/imap.rb | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 8c831cf703..e64f48070d 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -227,11 +227,6 @@ module Net # it raises a Net::OpenTimeout exception. The default value is 30 seconds. attr_reader :open_timeout - # Seconds to wait until reading one block (by one read(1) call). - # If the IMAP object cannot complete a read() within this time, - # it raises a Net::ReadTimeout exception. The default value is 60 seconds. - attr_reader :read_timeout - # The thread to receive exceptions. attr_accessor :client_thread @@ -1061,7 +1056,6 @@ module Net # If options[:ssl] is a hash, it's passed to # OpenSSL::SSL::SSLContext#set_params as parameters. # open_timeout:: Seconds to wait until a connection is opened - # read_timeout:: Seconds to wait until reading one block # # The most common errors are: # @@ -1091,7 +1085,6 @@ module Net @tag_prefix = "RUBY" @tagno = 0 @open_timeout = options[:open_timeout] || 30 - @read_timeout = options[:read_timeout] || 60 @parser = ResponseParser.new @sock = tcp_socket(@host, @port) begin @@ -1222,35 +1215,14 @@ module Net end end - def get_response_data(length, terminator = nil) - str = nil - buff = String.new - while true - str = @sock.read_nonblock(length, :exception => false) - case str - when :wait_readable - @sock.to_io.wait_readable(@read_timeout) or - raise Net::ReadTimeout, "#{@host}:#{@port} read timeout (exceeds #{@read_timeout} seconds)" - when nil - break - else - buff.concat(str) - if terminator ? buff.include?(terminator) : (buff.length >= length) - break - end - end - end - buff - end - def get_response buff = String.new while true - s = get_response_data(1, CRLF) - break if s.length == 0 + s = @sock.gets(CRLF) + break unless s buff.concat(s) if /\{(\d+)\}\r\n/n =~ s - s = get_response_data($1.to_i) + s = @sock.read($1.to_i) buff.concat(s) else break -- cgit v1.2.3