]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei q: fix auth IMAP --output with remote mboxrd
authorEric Wong <e@80x24.org>
Mon, 5 Apr 2021 10:27:52 +0000 (10:27 +0000)
committerEric Wong <e@80x24.org>
Mon, 5 Apr 2021 19:10:16 +0000 (19:10 +0000)
IMAP authentication info is only shared amongst lei2mail workers,
so we must ensure all IMAP writes go through lei2mail workers
even if we don't have to access the mail through git.

This allows us to decouple the latency of the remote mboxrd from
the latency of the IMAP --output at the expense of extra IPC
overhead within our own processes.

lib/PublicInbox/LeiOverview.pm
lib/PublicInbox/LeiToMail.pm
lib/PublicInbox/LeiXSearch.pm

index cdd9ee04766978b0151d5769a89f38d4ac294c6c..bfb8b1435ff25f21e5ea603138d8138c5eab964b 100644 (file)
@@ -195,7 +195,7 @@ sub _json_pretty {
 }
 
 sub ovv_each_smsg_cb { # runs in wq worker usually
-       my ($self, $lei, $ibxish) = @_;
+       my ($self, $lei) = @_;
        my ($json, $dedupe);
        if (my $pkg = $self->{json}) {
                $json = $pkg->new;
@@ -208,17 +208,11 @@ sub ovv_each_smsg_cb { # runs in wq worker usually
                $dedupe->prepare_dedupe;
        }
        $lei->{ovv_buf} = \(my $buf = '') if !$l2m;
-       if ($l2m && !$ibxish) { # remote https?:// mboxrd
-               my $wcb = $l2m->write_cb($lei);
-               sub {
-                       my ($smsg, undef, $eml) = @_; # no mitem in $_[1]
-                       $wcb->(undef, $smsg, $eml);
-               };
-       } elsif ($l2m && $l2m->{-wq_s1}) {
+       if ($l2m) {
                sub {
-                       my ($smsg, $mitem) = @_;
+                       my ($smsg, $mitem, $eml) = @_;
                        $smsg->{pct} = get_pct($mitem) if $mitem;
-                       $l2m->wq_io_do('write_mail', [], $smsg);
+                       $l2m->wq_io_do('write_mail', [], $smsg, $eml);
                }
        } elsif ($self->{fmt} =~ /\A(concat)?json\z/ && $lei->{opt}->{pretty}) {
                my $EOR = ($1//'') eq 'concat' ? "\n}" : "\n},";
index 9411313bae891c29fa3eafae78567306fefd665a..70164e40b672417fa01fcac159b69d151ae062d5 100644 (file)
@@ -583,7 +583,8 @@ sub poke_dst {
 }
 
 sub write_mail { # via ->wq_io_do
-       my ($self, $smsg) = @_;
+       my ($self, $smsg, $eml) = @_;
+       return $self->{wcb}->(undef, $smsg, $eml) if $eml;
        $self->{lei}->{ale}->git->cat_async($smsg->{blob}, \&git_to_mail,
                                [$self->{wcb}, $smsg]);
 }
index 2b23e8e9efe1c20e55e199bb44bc8f3b4bf8e194..692d5e54a7322a79446939cdb0ecd571ee46bd36 100644 (file)
@@ -153,7 +153,7 @@ sub query_thread_mset { # for --threads
        return warn("$desc not indexed by Xapian\n") unless ($srch && $over);
        my $mo = { %{$lei->{mset_opt}} };
        my $mset;
-       my $each_smsg = $lei->{ovv}->ovv_each_smsg_cb($lei, $ibxish);
+       my $each_smsg = $lei->{ovv}->ovv_each_smsg_cb($lei);
        my $can_kw = !!$ibxish->can('msg_keywords');
        my $fl = $lei->{opt}->{threads} > 1 ? 1 : undef;
        do {
@@ -196,7 +196,7 @@ sub query_mset { # non-parallel for non-"--threads" users
        for my $loc (locals($self)) {
                attach_external($self, $loc);
        }
-       my $each_smsg = $lei->{ovv}->ovv_each_smsg_cb($lei, $self);
+       my $each_smsg = $lei->{ovv}->ovv_each_smsg_cb($lei);
        do {
                $mset = $self->mset($mo->{qstr}, $mo);
                mset_progress($lei, 'xsearch', $mset->size,