about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-11-08 03:26:13 +0000
committerEric Wong <normalperson@yhbt.net>2011-11-08 03:26:13 +0000
commit27afdca06806f0c77be3625055539ab3331f5b3e (patch)
treed8079e0b4b8c931509e87c7a20bb9edc7d4fe8d7
parent1a5b3487e5a38a4897a6461b3907cd6bde501e0c (diff)
downloadmogilefs-client-27afdca06806f0c77be3625055539ab3331f5b3e.tar.gz
Our custom copy_stream needs to flush data like it does
under 1.9.  1.8 also can't do a blocking open(2) on a FIFO
in a native thread so we'll fork() instead.
-rw-r--r--lib/mogilefs/copy_stream.rb1
-rw-r--r--test/integration.rb4
-rw-r--r--test/test_mogilefs_integration_large_pipe.rb5
3 files changed, 8 insertions, 2 deletions
diff --git a/lib/mogilefs/copy_stream.rb b/lib/mogilefs/copy_stream.rb
index 01735cd..b928031 100644
--- a/lib/mogilefs/copy_stream.rb
+++ b/lib/mogilefs/copy_stream.rb
@@ -18,6 +18,7 @@ module MogileFS::CopyStream # :nodoc:
         written += dst.write(buf)
       end
     end
+    dst.flush if dst.respond_to?(:flush)
     written
     ensure
       src_io.close if String === src
diff --git a/test/integration.rb b/test/integration.rb
index f3fd618..837bd1f 100644
--- a/test/integration.rb
+++ b/test/integration.rb
@@ -4,6 +4,10 @@ require './test/exec'
 class TestMogIntegration < Test::Unit::TestCase
   include TestExec
 
+  def test_dummy
+    assert true, "Ruby 1.8 Test::Unit is broken"
+  end
+
   def setup
     @to_close = []
     @trackers = ENV["MOG_TEST_TRACKERS"].split(/,/)
diff --git a/test/test_mogilefs_integration_large_pipe.rb b/test/test_mogilefs_integration_large_pipe.rb
index afc62e5..afc252e 100644
--- a/test/test_mogilefs_integration_large_pipe.rb
+++ b/test/test_mogilefs_integration_large_pipe.rb
@@ -39,13 +39,14 @@ class TestMogileFSLargePipe< TestMogIntegration
     tmp_path = tmp.path
     File.unlink(tmp_path)
     x!("mkfifo", tmp_path)
-    th = Thread.new do
+    pid = fork do
       File.open(tmp_path, "wb") do |w|
         nr.times { w.write(junk) }
       end
     end
     assert_equal(nr * junk.size, @client.store_file("fifo", nil, tmp_path))
-    th.join
+    _, status = Process.waitpid2(pid)
+    assert status.success?, status.inspect
     fifo_sha1 = @client.get_file_data("fifo") { |rd| sha1read(rd) }
     assert_equal sha1, fifo_sha1
   end