diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-03-24 22:34:14 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-03-24 22:35:45 -0700 |
commit | 65f9a224dfda3ac8b0ee9290b456d23ece32a053 (patch) | |
tree | 568385e5519273373f8eff42edeaed2d846e8527 | |
parent | 76076d42db5cf16317823131f47570c8f80e22a1 (diff) | |
download | mogilefs-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.rb | 10 |
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 |