Skip to content

Commit 056a481

Browse files
committed
respect the reported number of bytes written
write() is blocking, but apparently may still not write the entire requested block (for various reasons). It is safest to NOT assume it wrote everything, and instead check the return value for the number of bytes actually written.
1 parent 01d2645 commit 056a481

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/mongo/socket.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,8 @@ def write_without_timeout(*args)
491491
buf = buf.to_s
492492
i = 0
493493
while i < buf.length
494-
chunk = buf[i...i+WRITE_CHUNK_SIZE]
495-
@socket.write(chunk)
496-
i += WRITE_CHUNK_SIZE
494+
chunk = buf[i, WRITE_CHUNK_SIZE]
495+
i += @socket.write(chunk)
497496
end
498497
end
499498
end

0 commit comments

Comments
 (0)