1 # Copyright (C) 2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 package PublicInbox::Gcf2Client;
5 use parent 'PublicInbox::Git';
6 use PublicInbox::Spawn qw(popen_rd);
10 my $self = shift->SUPER::new('/nonexistent');
12 pipe($out_r, $out_w) or $self->fail("pipe failed: $!");
13 my $cmd = [ 'public-inbox-gcf2' ];
14 @$self{qw(in pid)} = popen_rd($cmd, undef, { 0 => $out_r });
15 $self->{inflight} = [];
16 $self->{out} = $out_w;
17 fcntl($out_w, 1031, 4096) if $^O eq 'linux'; # 1031: F_SETPIPE_SZ
23 my ($self, $git_dir) = @_;
25 # ensure buffers are drained, length($git_dir) may exceed
26 # PIPE_BUF on platforms where PIPE_BUF is only 512 bytes
27 my $inflight = $self->{inflight};
28 while (scalar(@$inflight)) {
29 $self->cat_async_step($inflight);
31 print { $self->{out} } $git_dir, "\n" or
32 $self->fail("write error: $!");