diff options
author | Eric Wong <e@80x24.org> | 2015-09-25 02:27:55 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-09-25 02:29:08 +0000 |
commit | aba24c12b87acfe2766d6e9435b4c80de70ad5ba (patch) | |
tree | 39a2557984864f48790e1fac5d8c3a22b22c4907 /lib | |
parent | f233800d169c9ccaea1d2a4bdccf9dee6853d82b (diff) | |
download | public-inbox-aba24c12b87acfe2766d6e9435b4c80de70ad5ba.tar.gz |
I've yet to hit it, but syswrite has chance of returning EINTR on a blocking pipe.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/GitCatFile.pm | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/lib/PublicInbox/GitCatFile.pm b/lib/PublicInbox/GitCatFile.pm index 48ae6734..3fced28d 100644 --- a/lib/PublicInbox/GitCatFile.pm +++ b/lib/PublicInbox/GitCatFile.pm @@ -7,6 +7,7 @@ package PublicInbox::GitCatFile; use strict; use warnings; use POSIX qw(dup2); +require IO::Handle; sub new { my ($class, $git_dir) = @_; @@ -31,6 +32,7 @@ sub _cat_file_begin { } close $out_r or die "close failed: $!\n"; close $in_w or die "close failed: $!\n"; + $out_w->autoflush(1); $self->{in} = $in_r; $self->{out} = $out_w; @@ -40,16 +42,8 @@ sub _cat_file_begin { sub cat_file { my ($self, $object, $sizeref) = @_; - $object .= "\n"; - my $len = length($object); - $self->_cat_file_begin; - my $written = syswrite($self->{out}, $object); - if (!defined $written) { - die "pipe write error: $!\n"; - } elsif ($written != $len) { - die "wrote too little to pipe ($written < $len)\n"; - } + print { $self->{out} } $object, "\n" or die "pipe write error: $!\n"; my $in = $self->{in}; my $head = <$in>; |