parallel: Fixed: bug #42329: --line-buffer gives wrong output

This commit is contained in:
Ole Tange 2014-05-12 09:27:28 +02:00
parent 4b4266c466
commit 7a018602da
4 changed files with 25 additions and 7 deletions

View file

@ -214,9 +214,9 @@ cc:Tim Cuthbertson <tim3d.junk@gmail.com>,
Ryoichiro Suzuki <ryoichiro.suzuki@gmail.com>, Ryoichiro Suzuki <ryoichiro.suzuki@gmail.com>,
Jesse Alama <jesse.alama@gmail.com> Jesse Alama <jesse.alama@gmail.com>
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: New in this release:
@ -227,8 +227,12 @@ New in this release:
* BioLite uses GNU Parallel: https://bitbucket.org/caseywdunn/biolite * 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/ * 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. * Bug fixes and man page updates.
GNU Parallel - For people who live life in the parallel lane. GNU Parallel - For people who live life in the parallel lane.

View file

@ -4388,12 +4388,13 @@ sub openoutputfiles {
} else { } else {
# Set reading FD # Set reading FD
for my $fdno (1,2) { for my $fdno (1,2) {
my $fdw = $self->fh($fdno,'w'); # Re-open the file for reading
# Duplicate filehandle, so fdw can be closed seperately # so fdw can be closed seperately
open(my $fdr,"<&",$fdw) || die; # and fdr can be seeked seperately (for --line-buffer)
open(my $fdr,"<", $self->fh($fdno,'name')) || die;
$self->set_fh($fdno,'r',$fdr); $self->set_fh($fdno,'r',$fdr);
# Unlink if required # Unlink if required
unlink $self->fh($fdno,"unlink"); $Global::debug or unlink $self->fh($fdno,"unlink");
} }
} }
if($opt::linebuffer) { if($opt::linebuffer) {
@ -5240,7 +5241,13 @@ sub print {
# This seek will clear EOF # This seek will clear EOF
seek $in_fh, tell($in_fh), 0; seek $in_fh, tell($in_fh), 0;
# The read is non-blocking: The $in_fh is set to non-blocking. # 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 # Append to $$partial
# Find the last \n # Find the last \n
my $i = rindex($$partial,"\n"); my $i = rindex($$partial,"\n");

View file

@ -4,6 +4,10 @@ rm -rf tmp 2>/dev/null
cp -a input-files/testdir2 tmp cp -a input-files/testdir2 tmp
cat <<'EOF' | sed -e 's/;$/; /;s/$SERVER1/'$SERVER1'/;s/$SERVER2/'$SERVER2'/' | stdout parallel -j0 -k -L1 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'; echo '### Test \0 as recend';
printf "a\0b\0c\0" | parallel --recend '\0' -k -N1 --pipe cat -v \; echo; 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 printf "\0a\0b\0c" | parallel --recstart '\0' -k -N1 --pipe cat -v \; echo

View file

@ -1,3 +1,6 @@
### bug #42329: --line-buffer gives wrong output
168888897
78888897
### Test \0 as recend ### Test \0 as recend
a^@ a^@
b^@ b^@