1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

fix r63587

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2018-06-06 08:39:36 +00:00
parent 37ea653080
commit 685fdbe64c

View file

@ -245,32 +245,32 @@ module Net # :nodoc:
def write0(*strs) def write0(*strs)
@debug_output << strs.map(&:dump).join if @debug_output @debug_output << strs.map(&:dump).join if @debug_output
case len = @io.write_nonblock(strs.join, exception: false) orig_written_bytes = @written_bytes
when Integer
orig_len = len
strs.each_with_index do |str, i| strs.each_with_index do |str, i|
@written_bytes += str.bytesize need_retry = true
case len = @io.write_nonblock(str, exception: false)
when Integer
@written_bytes += len
len -= str.bytesize len -= str.bytesize
if len == 0 if len == 0
if strs.size == i+1 if strs.size == i+1
return orig_len return @written_bytes - orig_written_bytes
else else
strs = strs[i+1..] # rest need_retry = false
break # next string
end end
elsif len < 0 elsif len < 0
strs = strs[i..] # str and rest str = str[len, -len]
strs[0] = str[len, -len]
break
else # len > 0 else # len > 0
# next need_retry = false
end # next string
end end
# continue looping # continue looping
when :wait_writable when :wait_writable
@io.to_io.wait_writable(@write_timeout) or raise Net::WriteTimeout @io.to_io.wait_writable(@write_timeout) or raise Net::WriteTimeout
# continue looping # continue looping
end while true end while need_retry
end
end end
# #