about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/mogilefs/socket_common.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/mogilefs/socket_common.rb b/lib/mogilefs/socket_common.rb
index 298e3da..404acd0 100644
--- a/lib/mogilefs/socket_common.rb
+++ b/lib/mogilefs/socket_common.rb
@@ -43,9 +43,9 @@ module MogileFS::SocketCommon
   def read(size, buf = "", timeout = 5)
     timed_read(size, buf, timeout) or return # nil/EOF
 
-    while size > buf.bytesize
+    while (size -= buf.bytesize) > 0
       tmp ||= ""
-      timed_read(size - buf.bytesize, tmp, timeout) or return buf # truncated
+      timed_read(size, tmp, timeout) or return buf # truncated
       buf << tmp
     end