From 7a018602da500603787fb682ce92d8cba9579751 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Mon, 12 May 2014 09:27:28 +0200 Subject: [PATCH] parallel: Fixed: bug #42329: --line-buffer gives wrong output --- doc/release_new_version | 8 ++++++-- src/parallel | 17 ++++++++++++----- testsuite/tests-to-run/parallel-local23.sh | 4 ++++ testsuite/wanted-results/parallel-local23 | 3 +++ 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/doc/release_new_version b/doc/release_new_version index e899c3ea..c96706ad 100644 --- a/doc/release_new_version +++ b/doc/release_new_version @@ -214,9 +214,9 @@ cc:Tim Cuthbertson , Ryoichiro Suzuki , Jesse Alama -Subject: GNU Parallel 20140522 ('Nej') released +Subject: GNU Parallel 20140522 ('Boko Haram') released -GNU Parallel 20140522 ('Nej') has been released. It is available for download at: http://ftp.gnu.org/gnu/parallel/ +GNU Parallel 20140522 ('Boko Haram') has been released. It is available for download at: http://ftp.gnu.org/gnu/parallel/ New in this release: @@ -227,8 +227,12 @@ New in this release: * BioLite uses GNU Parallel: https://bitbucket.org/caseywdunn/biolite +* Isitdown uses GNU Parallel: http://www.isi.edu/~calvin/isitdown.md + * Convert FLAC to MP3 with GNU parallel http://www.blogobramje.nl/posts/Convert_FLAC_to_MP3_with_GNU_parallel/ +* No:The-Me GNU Parallel http://adityalaghate.in/gnu-parallel.html + * Bug fixes and man page updates. GNU Parallel - For people who live life in the parallel lane. diff --git a/src/parallel b/src/parallel index 5ad36c4f..6928ab20 100755 --- a/src/parallel +++ b/src/parallel @@ -4388,12 +4388,13 @@ sub openoutputfiles { } else { # Set reading FD for my $fdno (1,2) { - my $fdw = $self->fh($fdno,'w'); - # Duplicate filehandle, so fdw can be closed seperately - open(my $fdr,"<&",$fdw) || die; + # Re-open the file for reading + # so fdw can be closed seperately + # and fdr can be seeked seperately (for --line-buffer) + open(my $fdr,"<", $self->fh($fdno,'name')) || die; $self->set_fh($fdno,'r',$fdr); # Unlink if required - unlink $self->fh($fdno,"unlink"); + $Global::debug or unlink $self->fh($fdno,"unlink"); } } if($opt::linebuffer) { @@ -5240,7 +5241,13 @@ sub print { # This seek will clear EOF seek $in_fh, tell($in_fh), 0; # The read is non-blocking: The $in_fh is set to non-blocking. - while(read($in_fh,substr($$partial,length $$partial),1_000_000)) { + # 32768 --tag = 5.1s + # 327680 --tag = 4.4s + # 1024000 --tag = 4.4s + # 3276800 --tag = 4.3s + # 32768000 --tag = 4.7s + # 10240000 --tag = 4.3s + while(read($in_fh,substr($$partial,length $$partial),3276800)) { # Append to $$partial # Find the last \n my $i = rindex($$partial,"\n"); diff --git a/testsuite/tests-to-run/parallel-local23.sh b/testsuite/tests-to-run/parallel-local23.sh index 848d78ca..2b6b4068 100755 --- a/testsuite/tests-to-run/parallel-local23.sh +++ b/testsuite/tests-to-run/parallel-local23.sh @@ -4,6 +4,10 @@ rm -rf tmp 2>/dev/null cp -a input-files/testdir2 tmp cat <<'EOF' | sed -e 's/;$/; /;s/$SERVER1/'$SERVER1'/;s/$SERVER2/'$SERVER2'/' | stdout parallel -j0 -k -L1 +echo '### bug #42329: --line-buffer gives wrong output'; + parallel --line-buffer --tag seq ::: 10000000 | wc -c; + parallel --line-buffer seq ::: 10000000 | wc -c + echo '### Test \0 as recend'; printf "a\0b\0c\0" | parallel --recend '\0' -k -N1 --pipe cat -v \; echo; printf "\0a\0b\0c" | parallel --recstart '\0' -k -N1 --pipe cat -v \; echo diff --git a/testsuite/wanted-results/parallel-local23 b/testsuite/wanted-results/parallel-local23 index 25a7bb62..2114902e 100644 --- a/testsuite/wanted-results/parallel-local23 +++ b/testsuite/wanted-results/parallel-local23 @@ -1,3 +1,6 @@ +### bug #42329: --line-buffer gives wrong output +168888897 +78888897 ### Test \0 as recend a^@ b^@