From 79c034bf6e2a64c09d77e2ac4bf734347d686559 Mon Sep 17 00:00:00 2001 From: "Eric Wong (Contractor, The Linux Foundation)" Date: Mon, 19 Mar 2018 07:51:09 +0000 Subject: extmsg: rework partial MID matching to favor current inbox The current inbox is more important for partial Message-ID matching, so we try harder on that to fix common errors before moving onto other inboxes. Then, prevent expensive scanning of other inboxes by requiring a Message-ID length of at least 16 bytes. Finally, we limit the overall partial responses to 200 when scanning other inboxes to avoid excessive memory usage. --- lib/PublicInbox/ExtMsg.pm | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'lib/PublicInbox/ExtMsg.pm') diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm index ab9591f9..e0aabfb1 100644 --- a/lib/PublicInbox/ExtMsg.pm +++ b/lib/PublicInbox/ExtMsg.pm @@ -84,17 +84,33 @@ sub ext_msg { my $n_partial = 0; my @partial; - eval { require PublicInbox::Msgmap }; - my $have_mm = $@ ? 0 : 1; - if ($have_mm) { + if (my $mm = $cur->mm) { + my $tmp_mid = $mid; + my $res = $mm->mid_prefixes($tmp_mid, 100); + if ($res && scalar(@$res)) { + $n_partial += scalar(@$res); + push @partial, [ $cur, $res ]; + # fixup common errors: + } elsif ($tmp_mid =~ s,/[tTf],,) { + $res = $mm->mid_prefixes($tmp_mid, 100); + if ($res && scalar(@$res)) { + $n_partial += scalar(@$res); + push @partial, [ $cur, $res ]; + } + } + } + + # can't find a partial match in current inbox, try the others: + if (!$n_partial && length($mid) >= 16) { my $tmp_mid = $mid; again: - unshift @ibx, $cur; foreach my $ibx (@ibx) { my $mm = $ibx->mm or next; - if (my $res = $mm->mid_prefixes($tmp_mid)) { + my $res = $mm->mid_prefixes($tmp_mid, 100); + if ($res && scalar(@$res)) { $n_partial += scalar(@$res); push @partial, [ $ibx, $res ]; + last if $n_partial >= 100; } } # fixup common errors: -- cgit v1.2.3-24-ge0c7 From 3e8a4842d3f0ec51bab024322a934b91ace6f4ed Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 27 Mar 2018 10:46:10 +0000 Subject: extmsg: use news.gmane.org for Message-ID lookups http://mid.gmane.org/ has not worked for a while, but their NNTP server continues to work. Use that and perhaps give NNTP more exposure. Reported-by: Jonathan Corbet --- lib/PublicInbox/ExtMsg.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/PublicInbox/ExtMsg.pm') diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm index e0aabfb1..760614df 100644 --- a/lib/PublicInbox/ExtMsg.pm +++ b/lib/PublicInbox/ExtMsg.pm @@ -17,7 +17,7 @@ our @EXT_URL = ( # leading "//" denotes protocol-relative (http:// or https://) '//marc.info/?i=%s', '//www.mail-archive.com/search?l=mid&q=%s', - 'http://mid.gmane.org/%s', + 'nntp://news.gmane.org/%s', 'https://lists.debian.org/msgid-search/%s', '//docs.FreeBSD.org/cgi/mid.cgi?db=mid&id=%s', 'https://www.w3.org/mid/%s', -- cgit v1.2.3-24-ge0c7