Simplify implementation of scheduler io_read and io_write. (#6527)

This commit is contained in:
Samuel Williams 2022-10-12 15:56:35 +13:00 committed by GitHub
parent 4e29ca0c40
commit 04d291a490
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: git 2022-10-12 11:56:58 +09:00
Merged-By: ioquatix <samuel@codeotaku.com>

View File

@ -269,15 +269,14 @@ class IOBufferScheduler < Scheduler
total = 0
io.nonblock = true
while length >= 0
while true
maximum_size = buffer.size - offset
result = blocking{buffer.read(io, maximum_size, offset)}
if result > 0
total += result
offset += result
break if result >= length
break if total >= length
elsif result == 0
break
elsif result == EAGAIN
@ -298,15 +297,14 @@ class IOBufferScheduler < Scheduler
total = 0
io.nonblock = true
while length >= 0
while true
maximum_size = buffer.size - offset
result = blocking{buffer.write(io, maximum_size, offset)}
if result > 0
total += result
offset += result
break if result >= length
break if total >= length
elsif result == 0
break
elsif result == EAGAIN