[ARVADOS] created: bfb2ed548fb1334364b45db87692ba9e0885f862

git at public.curoverse.com git at public.curoverse.com
Wed Jul 30 16:17:54 EDT 2014


        at  bfb2ed548fb1334364b45db87692ba9e0885f862 (commit)


commit bfb2ed548fb1334364b45db87692ba9e0885f862
Author: Tom Clegg <tom at curoverse.com>
Date:   Wed Jul 30 16:17:49 2014 -0400

    3425: When reading from arv-get, repeat sysread until error or eof.

diff --git a/sdk/cli/bin/crunch-job b/sdk/cli/bin/crunch-job
index 30f06b8..8d9afaa 100755
--- a/sdk/cli/bin/crunch-job
+++ b/sdk/cli/bin/crunch-job
@@ -1179,7 +1179,20 @@ sub fetch_block
 
   my $cmd = "arv-get \Q$hash\E";
   open($keep, '-|', $cmd) or die "fetch_block: $cmd: $!";
-  sysread($keep, $output_block, 64 * 1024 * 1024);
+  $output_block = '';
+  while (1) {
+    my $buf;
+    my $bytes = sysread($keep, $buf, 64 * 1024 * 1024);
+    if (!defined $bytes) {
+      die "reading from arv-get: $!";
+    } elsif ($bytes == 0) {
+      # sysread returns 0 at the end of the pipe.
+      last;
+    } else {
+      # some bytes were read into buf.
+      $output_block .= $buf;
+    }
+  }
   close $keep;
   return $output_block;
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list