X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLeiRemote.pm;h=54750062fd5f18c0c680c672f6eb544d04a77c95;hb=4b5a1b5787edee2a3b6cc10a3ccc5721f1414268;hp=e7deecb8b7c3847f717349b3935f4f788b6b621a;hpb=7d576adffbbd61f04278937d882d7ffde570cecd;p=public-inbox.git diff --git a/lib/PublicInbox/LeiRemote.pm b/lib/PublicInbox/LeiRemote.pm index e7deecb8..54750062 100644 --- a/lib/PublicInbox/LeiRemote.pm +++ b/lib/PublicInbox/LeiRemote.pm @@ -9,10 +9,10 @@ package PublicInbox::LeiRemote; use v5.10.1; use strict; use IO::Uncompress::Gunzip; -use PublicInbox::OnDestroy; use PublicInbox::MboxReader; use PublicInbox::Spawn qw(popen_rd); use PublicInbox::LeiCurl; +use PublicInbox::AutoReap; use PublicInbox::ContentHash qw(git_sha); sub new { @@ -28,11 +28,11 @@ sub _each_mboxrd_eml { # callback for MboxReader->mboxrd my $xoids = $lei->{ale}->xoids_for($eml, 1); my $smsg = bless {}, 'PublicInbox::Smsg'; if ($lei->{sto} && !$xoids) { # memoize locally - my $res = $lei->{sto}->ipc_do('add_eml', $eml); + my $res = $lei->{sto}->wq_do('add_eml', $eml); $smsg = $res if ref($res) eq ref($smsg); } $smsg->{blob} //= $xoids ? (keys(%$xoids))[0] - : git_sha(1, $eml)->hexdigest; + : $lei->git_oid($eml)->hexdigest; $smsg->populate($eml); $smsg->{mid} //= '(none)'; push @{$self->{smsg}}, $smsg; @@ -47,17 +47,14 @@ sub mset { $uri->query_form(q => $qstr, x => 'm', r => 1); # r=1: relevance my $cmd = $curl->for_uri($self->{lei}, $uri); $self->{lei}->qerr("# $cmd"); - my $rdr = { 2 => $lei->{2}, pgid => 0 }; - my ($fh, $pid) = popen_rd($cmd, undef, $rdr); - my $reap = PublicInbox::OnDestroy->new($lei->can('sigint_reap'), $pid); + my ($fh, $pid) = popen_rd($cmd, undef, { 2 => $lei->{2} }); + my $ar = PublicInbox::AutoReap->new($pid); $self->{smsg} = []; $fh = IO::Uncompress::Gunzip->new($fh, MultiStream => 1); PublicInbox::MboxReader->mboxrd($fh, \&_each_mboxrd_eml, $self); - my $err = waitpid($pid, 0) == $pid ? undef - : "BUG: waitpid($cmd): $!"; - @$reap = (); # cancel OnDestroy - my $wait = $self->{lei}->{sto}->ipc_do('done'); - die $err if $err; + my $wait = $self->{lei}->{sto}->wq_do('done'); + $ar->join; + $lei->child_error($?) if $?; $self; # we are the mset (and $ibx, and $self) } @@ -75,7 +72,7 @@ sub smsg_eml { if (my $bref = $self->{lei}->ale->git->cat_file($smsg->{blob})) { return PublicInbox::Eml->new($bref); } - $self->{lei}->err("E: $self->{uri} $smsg->{blob} gone <$smsg->{mid}>"); + warn("E: $self->{uri} $smsg->{blob} gone <$smsg->{mid}>\n"); undef; }