aboutsummaryrefslogtreecommitdiffstats
path: root/lib/net
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-06 08:39:36 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-06 08:39:36 +0000
commit45de39a55534b4d1604a08ae6cf99e23ac93dd57 (patch)
tree4baa4a590426f360bc5a7c23c5bb3f74ce2ec402 /lib/net
parentee92c219d184573dc0b858576aae7d562e983ddf (diff)
downloadruby-45de39a55534b4d1604a08ae6cf99e23ac93dd57.tar.gz
fix r63587
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net')
-rw-r--r--lib/net/protocol.rb36
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index 94903afdfc..527b17c4c0 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -245,32 +245,32 @@ module Net # :nodoc:
def write0(*strs)
@debug_output << strs.map(&:dump).join if @debug_output
- case len = @io.write_nonblock(strs.join, exception: false)
- when Integer
- orig_len = len
- strs.each_with_index do |str, i|
- @written_bytes += str.bytesize
+ orig_written_bytes = @written_bytes
+ strs.each_with_index do |str, i|
+ need_retry = true
+ case len = @io.write_nonblock(str, exception: false)
+ when Integer
+ @written_bytes += len
len -= str.bytesize
if len == 0
if strs.size == i+1
- return orig_len
+ return @written_bytes - orig_written_bytes
else
- strs = strs[i+1..] # rest
- break
+ need_retry = false
+ # next string
end
elsif len < 0
- strs = strs[i..] # str and rest
- strs[0] = str[len, -len]
- break
+ str = str[len, -len]
else # len > 0
- # next
+ need_retry = false
+ # next string
end
- end
- # continue looping
- when :wait_writable
- @io.to_io.wait_writable(@write_timeout) or raise Net::WriteTimeout
- # continue looping
- end while true
+ # continue looping
+ when :wait_writable
+ @io.to_io.wait_writable(@write_timeout) or raise Net::WriteTimeout
+ # continue looping
+ end while need_retry
+ end
end
#