diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-11-02 02:14:46 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-11-02 02:14:46 +0000 |
commit | af2d9c971cee5a6896fa3da44adff72d5f2ae44a (patch) | |
tree | 52e2cd80c5491722dd8685651ecc34c024d0227e | |
parent | 4b8cc437c502e5fda86ac5935baf69ec5a585e74 (diff) | |
download | mogilefs-client-af2d9c971cee5a6896fa3da44adff72d5f2ae44a.tar.gz |
It's no longer used
-rw-r--r-- | lib/mogilefs/util.rb | 23 | ||||
-rw-r--r-- | test/test_util.rb | 62 |
2 files changed, 0 insertions, 85 deletions
diff --git a/lib/mogilefs/util.rb b/lib/mogilefs/util.rb index 596e038..1fb5ffb 100644 --- a/lib/mogilefs/util.rb +++ b/lib/mogilefs/util.rb @@ -79,29 +79,6 @@ module MogileFS::Util # should never get here end - def sysread_full(io_rd, size, timeout = nil, full_timeout = false) - tmp = [] # avoid expensive string concatenation with every loop iteration - reader = io_rd.method(timeout ? :read_nonblock : :sysread) - begin - while size > 0 - tmp << reader.call(size) - size -= tmp.last.size - end - rescue Errno::EAGAIN, Errno::EINTR - t0 = Time.now - 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 - end - tmp.join('') - end - class StoreContent < Proc def initialize(total_size, &writer_proc) @total_size = total_size diff --git a/test/test_util.rb b/test/test_util.rb index f733c88..416970b 100644 --- a/test/test_util.rb +++ b/test/test_util.rb @@ -56,66 +56,4 @@ class TestMogileFS__Util < Test::Unit::TestCase ensure t.destroy! end - - def test_sysread_slowly - nr = 10 - str = 'abcde' - expect = str * nr - rd, wr = IO.pipe - pid = fork do - rd.close - nr.times do - syswrite_full(wr, str) - sleep(0.1) - end - end - wr.close - buf = sysread_full(rd, expect.size) - assert_equal expect, buf - rd.close - ensure - Process.kill('TERM', pid) rescue nil - Process.waitpid(pid) rescue nil - end - - def test_sysread_timeout - nr = 10 - str = 'abcde' - expect = str * nr - rd, wr = IO.pipe - pid = fork do - rd.close - nr.times do - syswrite_full(wr, str) - sleep 1 - end - end - wr.close - assert_raises(MogileFS::Timeout) { sysread_full(rd, expect.size, 0.1) } - rd.close - ensure - Process.kill('TERM', pid) rescue nil - Process.waitpid(pid) rescue nil - end - - def test_sysread_full_timeout - nr = 100 - str = 'abcde' - expect = str * nr - rd, wr = IO.pipe - pid = fork do - rd.close - nr.times do - syswrite_full(wr, str) - sleep 0.01 - end - end - wr.close - assert_raises(MogileFS::Timeout) { sysread_full(rd,expect.size,0.1,true) } - rd.close - ensure - Process.kill('TERM', pid) rescue nil - Process.waitpid(pid) rescue nil - end - end |