about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-03-24 22:34:14 -0700
committerEric Wong <normalperson@yhbt.net>2009-03-24 22:35:45 -0700
commit65f9a224dfda3ac8b0ee9290b456d23ece32a053 (patch)
tree568385e5519273373f8eff42edeaed2d846e8527
parent76076d42db5cf16317823131f47570c8f80e22a1 (diff)
downloadmogilefs-client-65f9a224dfda3ac8b0ee9290b456d23ece32a053.tar.gz
full_timeout could be set if timeout is set.  Don't
croak on a NilClass error if we screw it up.  Also,
correctly detect readiness when checking the return
value of IO.select.
-rw-r--r--lib/mogilefs/util.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/mogilefs/util.rb b/lib/mogilefs/util.rb
index 28c7d44..b147dd4 100644
--- a/lib/mogilefs/util.rb
+++ b/lib/mogilefs/util.rb
@@ -77,10 +77,12 @@ module MogileFS::Util
       end
     rescue Errno::EAGAIN, Errno::EINTR
       t0 = Time.now
-      ready = IO.select([ io_rd ], nil, nil, timeout)
-      timeout -= (Time.now - t0) if full_timeout
-      if ready != [ io_rd ] || timeout < 0
-        raise MogileFS::Timeout, 'sysread_full timeout'
+      r = IO.select([ io_rd ], nil, nil, timeout)
+      if timeout
+        timeout -= (Time.now - t0) if full_timeout
+        if !(r && r[0]) || timeout < 0
+          raise MogileFS::Timeout, 'sysread_full timeout'
+        end
       end
       retry
     rescue EOFError