diff options
author | Matthew Draper <matthew@trebex.net> | 2012-02-28 23:39:09 +1030 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2012-02-28 20:37:23 +0000 |
commit | 8a3f48341248b919b5c4816bf4f7079eb35d6882 (patch) | |
tree | 057b62e8a24fef38a4961648955c82f57f777ce8 /lib/mogilefs/socket_common.rb | |
parent | 55365e01dc0b2b5db01441004f4c6921d1fd04d6 (diff) | |
download | mogilefs-client-8a3f48341248b919b5c4816bf4f7079eb35d6882.tar.gz |
Leave size unchanged, so it's available for easy comparison with buf.bytesize. [ew: added test case] Acked-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 'lib/mogilefs/socket_common.rb')
-rw-r--r-- | lib/mogilefs/socket_common.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/mogilefs/socket_common.rb b/lib/mogilefs/socket_common.rb index a716d35..5ba8c10 100644 --- a/lib/mogilefs/socket_common.rb +++ b/lib/mogilefs/socket_common.rb @@ -44,9 +44,9 @@ module MogileFS::SocketCommon def read(size, buf = "", timeout = 5) timed_read(size, buf, timeout) or return # nil/EOF - while (size -= buf.bytesize) > 0 + while (remaining = size - buf.bytesize) > 0 tmp ||= "" - timed_read(size, tmp, timeout) or return buf # truncated + timed_read(remaining, tmp, timeout) or return buf # truncated buf << tmp end |