]> Sergey Matveev's repositories - public-inbox.git/log
public-inbox.git
4 years ago*idx: pass $smsg in more places instead of many args
Eric Wong [Fri, 20 Mar 2020 08:18:18 +0000 (08:18 +0000)]
*idx: pass $smsg in more places instead of many args

We can pass blessed PublicInbox::Smsg objects to internal
indexing APIs instead of having long parameter lists in some
places.  The end goal is to avoid parsing redundant information
each step of the way and hopefully make things more
understandable.

4 years agooveridx: parse_references: less error-prone args
Eric Wong [Fri, 20 Mar 2020 08:18:17 +0000 (08:18 +0000)]
overidx: parse_references: less error-prone args

Favor `$smsg->{mid}' instead of `$mid0' to reduce parameters
down-the-line, but favor passing the Email::MIME::Header object
around instead of relying on the bloat-prone `$smsg->{mime}'
and calling ->header_obj on it.

4 years agosmsg: to_doc_data: use existing fields
Eric Wong [Fri, 20 Mar 2020 08:18:16 +0000 (08:18 +0000)]
smsg: to_doc_data: use existing fields

No need to pass extra parameters to this method, since
smsg has universal meanings for {blob} and {mid}.

4 years agorename PublicInbox::SearchMsg => PublicInbox::Smsg
Eric Wong [Fri, 20 Mar 2020 08:18:15 +0000 (08:18 +0000)]
rename PublicInbox::SearchMsg => PublicInbox::Smsg

Since the introduction of over.sqlite3, SearchMsg is not tied to
our search functionality in any way, so stop confusing ourselves
and future hackers by just calling it "PublicInbox::Smsg".

Add a missing "use" in ExtMsg while we're at it.

4 years agov2writable: preserve timestamps from import
Eric Wong [Fri, 20 Mar 2020 08:18:14 +0000 (08:18 +0000)]
v2writable: preserve timestamps from import

While v2 indexing is triggered immediately after writing the
commit to the git repository, there may be a gap between when
PublicInbox::Import generates a timestamp and when
PublicInbox::SearchIdx sees the message.  So follow the mirror
indexing behavior and take the to-be-indexed (time|date)stamps
directly from the git commit.

4 years agoindex: use git commit times on missing Date/Received
Eric Wong [Fri, 20 Mar 2020 08:18:13 +0000 (08:18 +0000)]
index: use git commit times on missing Date/Received

When indexing messages without Date: and/or Received: headers,
fall back to using timestamps originally recorded by git in the
commit object.  This allows git mirrors to preserve the import
datestamp and timestamp of a message according to what was fed
into git, instead of blindly falling back to the current time.

4 years agot/msgtime: skip test if timezone isn't UTC
Eric Wong [Sat, 21 Mar 2020 06:18:27 +0000 (01:18 -0500)]
t/msgtime: skip test if timezone isn't UTC

Date::Parse falls back to using the local timezone when
it's missing from an email, so only test in a reasonable
TZ (UTC) for server software.

4 years agot/www_listing: avoid 'once' warnings
Eric Wong [Sat, 21 Mar 2020 05:24:32 +0000 (05:24 +0000)]
t/www_listing: avoid 'once' warnings

We reach into the WwwListing package directly to retrieve
that JSON encoder/decoder object, and we can't rely on `use'
since WwwListing loading may fail if Plack is missing.

4 years agowwwlisting: use first successfully loaded JSON module
Eric Wong [Sat, 21 Mar 2020 01:10:33 +0000 (01:10 +0000)]
wwwlisting: use first successfully loaded JSON module

And not the last...

I only noticed this since JSON::PP::Boolean was spewing
redefinition warnings via overload.pm

Fixes: 8fb8fc52420ef669 ("wwwlisting: avoid lazy loading JSON module")
4 years agoexamples/*.psgi: add examples for -httpd
Eric Wong [Thu, 19 Mar 2020 23:55:50 +0000 (23:55 +0000)]
examples/*.psgi: add examples for -httpd

public-inbox-httpd should work with any PSGI files, so make
it more apparent to people reading .psgi examples.

4 years agoviewdiff: favor `qr' to precompile regexps
Eric Wong [Thu, 19 Mar 2020 08:32:56 +0000 (03:32 -0500)]
viewdiff: favor `qr' to precompile regexps

We can also avoid `o' regexp modifier, since it isn't
recommended by Perl upstream, anymore (although we don't
have any bugs or unintended behavior because of it).

4 years agodaemon: do more immortal allocations up front
Eric Wong [Thu, 19 Mar 2020 08:32:55 +0000 (03:32 -0500)]
daemon: do more immortal allocations up front

Doing immortal allocations late can cause those allocations
to end up in places where it fragments the heap.  So do more
things up front for long-lived daemons.

4 years agowww: avoid `state' usage to perform allocations up-front
Eric Wong [Thu, 19 Mar 2020 08:32:54 +0000 (03:32 -0500)]
www: avoid `state' usage to perform allocations up-front

We want WWW->preload to get as many immortal allocations done
as possible, and the `state' feature from Perl 5.10 prevents that.

4 years agowwwlisting: avoid lazy loading JSON module
Eric Wong [Thu, 19 Mar 2020 08:32:53 +0000 (03:32 -0500)]
wwwlisting: avoid lazy loading JSON module

We already lazy-load WwwListing for the CGI script, and
hiding another layer of lazy-loading makes things difficult
to do WWW->preload.

We want long-lived processes to do all long-lived allocations up
front to avoid fragmentation in the allocator, but we'll still
support short-lived processes by lazy-loading individual modules
in the PublicInbox::* namespace.

Mixing up allocation lifetimes (e.g. doing immortal allocations
while a large amount of space is taken by short-lived objects)
will cause fragmentation in any allocator which favors large
contiguous regions for performance reasons.  This includes any
malloc implementation which relies on sbrk() for the primary
heap, including glibc malloc.

4 years agowwwlisting: favor "use" over require
Eric Wong [Thu, 19 Mar 2020 08:32:52 +0000 (03:32 -0500)]
wwwlisting: favor "use" over require

"use" is also evaluated earlier than "require", so it is
favorable for compile-only checking.

4 years agowww: update ->preload for newer modules
Eric Wong [Thu, 19 Mar 2020 08:32:51 +0000 (03:32 -0500)]
www: update ->preload for newer modules

We'll also avoid explicitly loading standard library modules
like POSIX and Digest::SHA, here; instead we load our own
modules and let those load whatever non-PublicInbox:: modules
they need.

4 years agodoc: standards: add references to RFC 5322 (and RFC 822)
Eric Wong [Thu, 19 Mar 2020 07:51:53 +0000 (07:51 +0000)]
doc: standards: add references to RFC 5322 (and RFC 822)

RFC 5322 is the latest one in this line, but much documentation
and even command-line options in other programs (e.g. git) refer
to RFC 2822 or even RFC 822.

4 years agohttp: fix RFC conformance w.r.t. message length
Eric Wong [Tue, 17 Mar 2020 06:52:17 +0000 (06:52 +0000)]
http: fix RFC conformance w.r.t. message length

We need to favor "Transfer-Encoding: chunked" over the value of
the Content-Length header.  We should also reject bogus,
duplicate and/or unreasonable values for both these, since they
can trigger unexpected behavior when combined with other HTTP
parsers in proxies such as varnish, nginx, haproxy, etc...

See RFC 7230 (and RFC 2616) for more details:

https://tools.ietf.org/html/rfc7230
https://www.rfc-editor.org/errata_search.php?rfc=7230

4 years agoINSTALL: refer to the proper Debian version
Eric Wong [Tue, 3 Mar 2020 05:03:11 +0000 (05:03 +0000)]
INSTALL: refer to the proper Debian version

Debian 10.0 was released July 2019, so update our documentation
to reflect that.  While we're at it, fixup a broken footnote
reference for Inline::C, too.

4 years agodaemon: remove unused $parent_pipe variable
Eric Wong [Sat, 7 Mar 2020 12:15:23 +0000 (12:15 +0000)]
daemon: remove unused $parent_pipe variable

We can just create a ParentPipe and let PublicInbox::DS
manage its life cycle.  While we're at it, favor `\&coderef'
over `*coderef' so we're explicit about it being a code ref
and not some other ref type.

4 years agosearchmsg: allow lines (and bytes) to be zero
Eric Wong [Sat, 7 Mar 2020 10:57:02 +0000 (10:57 +0000)]
searchmsg: allow lines (and bytes) to be zero

We will occasionally see legit messages with zero lines,
be sure we index that count for NNTP clients.

I'm not sure about bytes being zero (aside from purged
messages), but we should've dealt with that earlier up
the stack.

4 years agogit: remove POSIX::dup2 import
Eric Wong [Tue, 3 Mar 2020 10:11:20 +0000 (10:11 +0000)]
git: remove POSIX::dup2 import

We rely on spawn/popen_rd for redirects, nowadays.

4 years agospawn: correctly handle error code
Eric Wong [Tue, 3 Mar 2020 09:50:57 +0000 (09:50 +0000)]
spawn: correctly handle error code

Both the C and pure Perl implementions of `pi_fork_exec'
returns `-1' on error, not `undef'.

4 years agomsgtime: assume +0000 if TZ missing when using Date::Parse
Eric Wong [Tue, 25 Feb 2020 09:23:03 +0000 (09:23 +0000)]
msgtime: assume +0000 if TZ missing when using Date::Parse

Some old emails don't have timezone offsets, since our
Date::Parse code path takes a liberal interpretation of dates,
fallback to using "+0000" as the timezone offset since it's
closer to the actual date of the message than whatever the
current date is.

Reported-by: Leah Neukirchen <leah@vuxu.org>
Link: https://public-inbox.org/meta/87h7zfemur.fsf@vuxu.org/
Fixes: ae80a3fdb53d7014 ("MsgTime.pm: Use strptime to compute the time zone")
4 years agoimport: drop '<' and '>' characters in addresses
Eric Wong [Wed, 26 Feb 2020 10:21:12 +0000 (10:21 +0000)]
import: drop '<' and '>' characters in addresses

Some strange "From:" lines will cause Email::Address::XS to
leave '<' (and presumably '>') in the address which
git-fast-import won't accept even if quoted.  Workaround this
problem by deleting '<' and '>' the same way we delete them for
the ident name.

Reported-by: Leah Neukirchen <leah@vuxu.org>
Link: https://public-inbox.org/meta/87h7zfemur.fsf@vuxu.org/
4 years agoINSTALL: update for 1.3.0+, clarify IO::Compress
Eric Wong [Thu, 27 Feb 2020 22:11:50 +0000 (16:11 -0600)]
INSTALL: update for 1.3.0+, clarify IO::Compress

IO::Compress is required for v2 inboxes and overview
indices, after all, but it is often pulled in by
other packages (HTTP::Message via Plack::Test).

4 years agodoc: design_www: document offline friendliness
Eric Wong [Thu, 27 Feb 2020 13:34:51 +0000 (13:34 +0000)]
doc: design_www: document offline friendliness

This isn't anything new and has been a part of the design
since the beginning, but it may not be apparent to some
folks.

4 years agosearchview: improve naming and simplify hash override
Eric Wong [Wed, 26 Feb 2020 00:44:05 +0000 (00:44 +0000)]
searchview: improve naming and simplify hash override

`%over' could be confused for the overview SQLite DB
instance, so call it `%override', instead.  There's
also no need to write a loop to override a hash when
the language can do it for us.

4 years agodoc: 1.4.0 release notes update
Eric Wong [Tue, 25 Feb 2020 22:57:38 +0000 (16:57 -0600)]
doc: 1.4.0 release notes update

Perhaps 1.4.0 will be a small release, after all (and also
smaller in terms of memory use :)

4 years agov2writable: lookup_content => content_exists
Eric Wong [Mon, 24 Feb 2020 08:08:22 +0000 (08:08 +0000)]
v2writable: lookup_content => content_exists

It only needs to return a boolean, since none of the current
callers care about the return value.  Thus avoid a hash table
assignment and use of `$smsg->{mime}', here.

4 years agov2writable: make remove return-compatible w/ Import::remove
Eric Wong [Mon, 24 Feb 2020 08:08:21 +0000 (08:08 +0000)]
v2writable: make remove return-compatible w/ Import::remove

Import::remove is a documented interface, and the return
value of the V2Writable work-alike should try to be compatible
with what Import implements.

4 years agoexamples/nginx_proxy: convert CRLF to LF
Eric Wong [Mon, 24 Feb 2020 07:33:28 +0000 (07:33 +0000)]
examples/nginx_proxy: convert CRLF to LF

It was the only file in our tree which had CRLF line endings,
so make it consistent with the rest.

4 years agoviewdiff: remove optional CR handling
Eric Wong [Mon, 24 Feb 2020 07:33:27 +0000 (07:33 +0000)]
viewdiff: remove optional CR handling

The only caller of `flush_diff' is `add_text_body', and that
already did CRLF conversion on the text part.  The regexps in
SolverGit still need to preserve CR, however, since that
actually applies patches (instead of rendering them), and we
need to preserve CRLF patches for CRLF files.

4 years agohval: ascii_html: drop CRLF => LF conversion
Eric Wong [Mon, 24 Feb 2020 07:33:26 +0000 (07:33 +0000)]
hval: ascii_html: drop CRLF => LF conversion

Instead, we add CRLF conversion to the only remaining place
which needs it, ViewVCS.  This save many redundant ops in in
many places.

The only other place where this mattered was in
View::add_text_body, but we already started doing CRLF
conversions when we added diff parsing and link generation for
ViewVCS.  Otherwise, all other places we used this was for
header viewing and Email::MIME doesn't preserve CRLF in headers.

4 years agoimport_vger_from_mbox: add --filter parameter
Eric Wong [Mon, 24 Feb 2020 00:17:24 +0000 (18:17 -0600)]
import_vger_from_mbox: add --filter parameter

It shouldn't be hard to make this into a more generic
importer not specific to vger lists.

4 years agoimport_vger_from_mbox: drop redundant "use" statements
Eric Wong [Mon, 24 Feb 2020 00:17:23 +0000 (18:17 -0600)]
import_vger_from_mbox: drop redundant "use" statements

PublicInbox::InboxWritable takes care of those imports.

4 years agosearchview: set obfuscation inbox properly
Eric Wong [Sun, 23 Feb 2020 22:47:15 +0000 (22:47 +0000)]
searchview: set obfuscation inbox properly

We never lookup `$ctx->{-obfuscate}' anywhere, as the
correct key is `$ctx->{-obfs_ibx}' since some of the
address obfuscation stuff is inbox-specific.

Note: some of the obfuscation stuff still needs tests,
but it's low-priority at the moment since I don't think
it's a good feature after all.

4 years agodoc: technical: document data structures
Eric Wong [Sun, 23 Feb 2020 12:27:30 +0000 (12:27 +0000)]
doc: technical: document data structures

Can't code without data structures, and we emphasize
data over code just about everywhere.

4 years agoINSTALL: s/repositories/inboxes/
Eric Wong [Sun, 23 Feb 2020 22:43:37 +0000 (22:43 +0000)]
INSTALL: s/repositories/inboxes/

Since v2 inboxes can be made of several git repositories,
consistently call them "inboxes", instead.

4 years agodoc: improve wording of "inbox" vs "repository"
Eric Wong [Sat, 22 Feb 2020 08:27:29 +0000 (08:27 +0000)]
doc: improve wording of "inbox" vs "repository"

Since v2 inboxes contain multiple git repositories, avoid the
use of the word "repository" when referring to inboxes as a
whole in most places.

4 years agoview: shorten life of MIME object for permalink
Eric Wong [Mon, 17 Feb 2020 11:00:48 +0000 (05:00 -0600)]
view: shorten life of MIME object for permalink

We don't need to hold onto the Email::MIME object across
multiple WwwResponse->getline calls, instead we can stuff
the rendered HTML of the first (and hopefully only) message
of the buffer into ctx->{-html_tip}.

4 years agodoc: design_www: document solver endpoint
Eric Wong [Sun, 16 Feb 2020 10:24:35 +0000 (10:24 +0000)]
doc: design_www: document solver endpoint

The blob regeneration (solving) part has been stable and
performant for over a year with no problems, even with web
crawlers constantly hitting it without needing rate limits.

All the other stuff is open to bikeshedding (as long as
my crappy hardware supports it :P)

4 years agoviewdiff: do not generate "a=" parameter if "b=" matches
Eric Wong [Sun, 16 Feb 2020 10:07:30 +0000 (04:07 -0600)]
viewdiff: do not generate "a=" parameter if "b=" matches

Long URLs waste bandwidth and redundant query parameters
make caching more difficult and expensive.

Fixes: ddec19694cbf0e1d ("viewdiff: rewrite and simplify")
4 years agoview: remove last Hval->new caller
Eric Wong [Sat, 15 Feb 2020 09:46:40 +0000 (09:46 +0000)]
view: remove last Hval->new caller

The object-oriented Hval API turned out to be less useful and
more clunky than I envisioned years ago, so get rid of it.
We'll no longer strip trailing whitespace from From: headers in
the HTML display, but I doubt anybody cares.

4 years agoview: escape ampersand in Message-IDs
Eric Wong [Sat, 15 Feb 2020 09:46:39 +0000 (09:46 +0000)]
view: escape ampersand in Message-IDs

We need to escape ampersands (and some other characters for href
attributes), so introduce a `mid_href' sub to do just that.

'<', '>' and '"'  were always escaped, so there's no risk of tag
or attribute injection, but creative Message-IDs could cause
confusion for some parsers and generate invalid URLs.

Start getting rid of the bloated, over-engineered OO Hval API
while we're at it, I only noticed this bug because I started
killing off Hval->new* callers.

4 years agoview: escape Subject HTML directly
Eric Wong [Sat, 15 Feb 2020 09:46:38 +0000 (09:46 +0000)]
view: escape Subject HTML directly

No need to use the over-engineered Hval OO API when the subject
is already normalized and there's no trailing spaces because of
normalization.

4 years agoview,searchview: avoid smsg method calls when using SQLite/Xapian
Eric Wong [Sat, 15 Feb 2020 09:46:37 +0000 (09:46 +0000)]
view,searchview: avoid smsg method calls when using SQLite/Xapian

We already pre-populate the hashref when loading $smsg
(PublicInbox::SearchMsg) objects out of over.sqlite3 or Xapian,
so making expensive method calls isn't necessary in those cases.

We only need to use the method calls when SQLite or Xapian are
not available or are being populated (such as during indexing).

4 years agoview: cleanup topic accumulation and dumping
Eric Wong [Sat, 15 Feb 2020 09:46:36 +0000 (09:46 +0000)]
view: cleanup topic accumulation and dumping

Avoid needlessly normalizing the subject when dumping, since
it's pushed into the @$topic array during accumulation in
normalized form.

We can also safely treat $smsg as a hashref and avoid
calling "->ds" as a method since we know we've got that
loaded via Over||Search and won't have to use Email::MIME
header lookup methods.

4 years agoview: dump_topics: better naming of top Subject
Eric Wong [Sat, 15 Feb 2020 09:46:35 +0000 (09:46 +0000)]
view: dump_topics: better naming of top Subject

We use `$top' in other places, so name it to `$top_subj'
consistently for `$subj' and `$prev_subj' comparisons down
the function.

4 years agoview: single id="t" for multi-Subject messages
Eric Wong [Sat, 15 Feb 2020 09:46:34 +0000 (09:46 +0000)]
view: single id="t" for multi-Subject messages

While multi-Subject messages are unfortunate, try not to
generate confusing/invalid HTML with multiple elements
having the same HTML id attribute.

4 years agoview: remove mhref arg from multipart_text_as_html
Eric Wong [Sat, 15 Feb 2020 09:46:33 +0000 (09:46 +0000)]
view: remove mhref arg from multipart_text_as_html

No point in passing something on stack only to stash it
into the $ctx which holds most other parameters used for
rendering the HTML.

4 years agot/msg_iter: test for X-UNKNOWN charset from Alpine
Eric Wong [Fri, 14 Feb 2020 07:05:22 +0000 (07:05 +0000)]
t/msg_iter: test for X-UNKNOWN charset from Alpine

A long overdue test for behavior established in 2016.

Fixes: 1b28cc7f00a866cb ("view: try assuming UTF-8 for bogus charsets")
4 years agodoc: update v1.3.0.eml with actual headers, start v1.4.0
Eric Wong [Mon, 10 Feb 2020 05:55:21 +0000 (23:55 -0600)]
doc: update v1.3.0.eml with actual headers, start v1.4.0

Bigger changes coming :>

4 years agopublic-inbox 1.3.0 v1.3.0
Eric Wong [Mon, 10 Feb 2020 05:40:27 +0000 (05:40 +0000)]
public-inbox 1.3.0

4 years agot/multi-mid: skip properly w/o DBD::SQLite
Eric Wong [Sat, 8 Feb 2020 18:30:40 +0000 (18:30 +0000)]
t/multi-mid: skip properly w/o DBD::SQLite

SearchIdx always requires DBD::SQLite, so only require it
after we've passed `require_mods(qw(DBD::SQLite))'.

4 years agoconvert: preserve indexlevel on conversions
Eric Wong [Sat, 8 Feb 2020 18:08:49 +0000 (18:08 +0000)]
convert: preserve indexlevel on conversions

We don't want to blow up users storage too badly when converting
v1 to v2 or break because they don't have Xapian bindings installed.

4 years agodoc: more 1.3.0 release notes updates
Eric Wong [Fri, 7 Feb 2020 08:31:58 +0000 (02:31 -0600)]
doc: more 1.3.0 release notes updates

4 years agodoc: mark some TODO items as done
Eric Wong [Fri, 7 Feb 2020 08:31:57 +0000 (02:31 -0600)]
doc: mark some TODO items as done

NNTP TLS and COMPRESS support and cgit spawning from
the WWW interface were implemented last year.

Given the lack of syscall number stability guarantee on the
OpenBSD and FreeBSD, I don't think supporting a pure-Perl kevent
is feasible.  Inline::C may still be an option since IO::KQueue
is abandoned, though, as it is for some Linux-only syscalls and
maybe some POSIX ones not covered by POSIX.pm.

4 years agodoc: update copyright for standards.perl
Eric Wong [Fri, 7 Feb 2020 08:31:56 +0000 (02:31 -0600)]
doc: update copyright for standards.perl

It was missing "(C)", so gnulib update-copyright missed it.

4 years agotests: switch to XML::TreePP for testing Atom feeds
Eric Wong [Thu, 6 Feb 2020 20:59:45 +0000 (20:59 +0000)]
tests: switch to XML::TreePP for testing Atom feeds

XML::Feed pulls in a lot of dependencies, some of which XS.
That makes testing with blead or any non-OS-supplied Perl
installations more time consuming and more difficult because
of the need to have development headers and libraries for
libexpat1 or libxml2.

Performance from libexpat1 or libxml2 for our small tests cases
isn't relevant, either, and the pure Perl XML::TreePP seems up
to the task.  It's also available in CentOS 7.x, FreeBSD 11.x,
and Debian, at least.

4 years agosyscall: support Linux x32 ABI
Eric Wong [Thu, 6 Feb 2020 08:49:36 +0000 (08:49 +0000)]
syscall: support Linux x32 ABI

The x32 ABI allows users to take advantage of the extra
registers on x86-64 without the bloat of 64-bit pointers and
longs.

This ought to be significant since Perl was designed when 32-bit
was prevalent; and the common structs for ops, hashes, scalars,
and arrays use longs (SSize_t/Size_t) for things which should
never need 64-bits when processing emails.

Debian's x32 port seems to work quite nicely under a chroot
on an amd64 Linux system.  All tests pass under x32, now.

4 years agotreewide: run update-copyrights from gnulib for 2019
Eric Wong [Thu, 6 Feb 2020 19:14:48 +0000 (13:14 -0600)]
treewide: run update-copyrights from gnulib for 2019

I didn't wait until September to do it, this year!

4 years agoMANIFEST: add flow.{ge,txt}
Eric Wong [Thu, 6 Feb 2020 19:11:49 +0000 (19:11 +0000)]
MANIFEST: add flow.{ge,txt}

Oops :x

4 years agodoc: v1: add a reference to git-filter-repo(1), too
Eric Wong [Thu, 6 Feb 2020 04:03:49 +0000 (22:03 -0600)]
doc: v1: add a reference to git-filter-repo(1), too

The git-filter-branch(1) manpage itself recommends git-filter-repo,
nowadays due to performance and safety problems.

4 years agodoc: txt2pre: auto-linkify manpage references
Eric Wong [Thu, 6 Feb 2020 04:03:48 +0000 (22:03 -0600)]
doc: txt2pre: auto-linkify manpage references

This can be more convenient for people browsing HTML docs
remotely or locally.

4 years agodoc: remove .x/ subdirectory for Xapian manpages
Eric Wong [Thu, 6 Feb 2020 04:03:47 +0000 (22:03 -0600)]
doc: remove .x/ subdirectory for Xapian manpages

There's no need to keep Xapian manpage renderings in a separate
subdirectory, after all.

Eliminating this difference between the local FS and URL path
will allow relative URLs to the Xapian manpages in our local
HTML documentation to work smoothly, since there was never any
".x/" path component for files served from public-inbox.org

4 years agodoc: add data flow diagram using Graph::Easy
Eric Wong [Thu, 6 Feb 2020 04:03:46 +0000 (22:03 -0600)]
doc: add data flow diagram using Graph::Easy

Maybe this can make it easier for new and potential
users to understand what's going on.

4 years agot/multi-mid: don't access ~/.public-inbox/config
Eric Wong [Thu, 6 Feb 2020 09:18:37 +0000 (09:18 +0000)]
t/multi-mid: don't access ~/.public-inbox/config

It can cause unpredictable behavior and also slow things down.

Followup-to: e4d3be19612b2082 ("t: localize the PI_CONFIG env")
4 years agodoc: recommend -compact after --reindex
Eric Wong [Tue, 4 Feb 2020 21:44:04 +0000 (21:44 +0000)]
doc: recommend -compact after --reindex

It's likely a user will be low on space after running --reindex,
so recommend the use of public-inbox-compact afterwards.

And add a few more notes about using public-inbox-compact to
clarify it's for inboxes-only (and not any old Xapian DBs) that
using xapian-compact(1) directly is error-prone and likely to
break things.

4 years agoover: simplify read-only vs read-write checking
Eric Wong [Tue, 4 Feb 2020 04:44:25 +0000 (04:44 +0000)]
over: simplify read-only vs read-write checking

No need to call ref() and do a string comparison.  Add some
extra tests using the {ReadOnly} attribute in DBI.pm.

4 years agoinbox: remove TODO item for msg_by_path
Eric Wong [Tue, 4 Feb 2020 04:44:24 +0000 (04:44 +0000)]
inbox: remove TODO item for msg_by_path

It's an old function which only gets called by inboxes w/o
SQLite indices.

4 years agoinbox: simplify ->description and ->cloneurl
Eric Wong [Tue, 4 Feb 2020 04:44:23 +0000 (04:44 +0000)]
inbox: simplify ->description and ->cloneurl

We can use "//=" from Perl 5.10 to simplify the logic for these
methods.  The use of chomp() in ->cloneurl was also unnecessary
since split(/\s+/s,...) already removes newlines.

4 years agowww: serve $INBOX_DIR/description as $INBOX_URL/description
Eric Wong [Tue, 4 Feb 2020 04:44:22 +0000 (04:44 +0000)]
www: serve $INBOX_DIR/description as $INBOX_URL/description

Instead of serving $INBOX_DIR/all.git/description, since
$INBOX_DIR/all.git/description is not described in the
default message when it's missing.

4 years agowww: stricter regexp for 405 errors
Eric Wong [Tue, 4 Feb 2020 04:44:21 +0000 (04:44 +0000)]
www: stricter regexp for 405 errors

We want to match "GET" and "HEAD" exactly, not requests which
start with "GET" or end with "HEAD".  This doesn't seem like
a real problem for public-inboxes which are actually public
data anyways.

4 years agodoc: spellling fixes for manpages
Eric Wong [Tue, 4 Feb 2020 11:15:15 +0000 (11:15 +0000)]
doc: spellling fixes for manpages

The wording for publicinbox.nntpserver was awkward, too, and I
took this as opportunity to hopefully clarify it and favor
"hostname" for Internet addresses, because we already use
"address" to mean "email address" in the config.

4 years agospawn: actually die on (vfork|fork) failures
Eric Wong [Sun, 2 Feb 2020 17:51:26 +0000 (17:51 +0000)]
spawn: actually die on (vfork|fork) failures

Commit 9f5a583694396f84 ("spawn (and thus popen_rd) die on failure")
was incomplete in that it only removed error checking for spawn
failures for non-(vfork|fork) calls, but the actual (vfork|fork)
PID result could still be undef.

Fixes: 9f5a583694396f84 ("spawn (and thus popen_rd) die on failure")
4 years agov2writable: more ways to detect online CPU count
Eric Wong [Sun, 2 Feb 2020 06:52:22 +0000 (06:52 +0000)]
v2writable: more ways to detect online CPU count

OpenBSD and FreeBSD support `getconf NPROCESSORS_ONLN` (no
leading underscore).  They may also have GNU nproc installed as
"gnproc".

We may also encounter Linux systems w/o GNU coreutils, but able
to use `getconf _NPROCESSORS_ONLN` (with leading underscore).

4 years agodoc: -convert: document switches
Eric Wong [Sun, 2 Feb 2020 06:52:21 +0000 (06:52 +0000)]
doc: -convert: document switches

These switches have always been there, but were not
documented until now.

4 years agoconvert: fix --no-index switch
Eric Wong [Sun, 2 Feb 2020 06:52:20 +0000 (06:52 +0000)]
convert: fix --no-index switch

The (currently undocumented) "--no-index" flag did not trigger
the V2Writable->done call necessary to make the import
successful.

Fixes: eea47b676127bcdb ("convert: preserve highwater mark from v1 msgmap")
4 years agoconvert: shift @ARGV explicitly
Eric Wong [Sun, 2 Feb 2020 06:52:19 +0000 (06:52 +0000)]
convert: shift @ARGV explicitly

Relying on implicit "@_" for shift fails with
TestCommon::_run_sub iff GetOptions modifies @ARGV.

4 years agosearchidxshard: rely on autoflush instead of ->flush
Eric Wong [Sun, 2 Feb 2020 06:52:18 +0000 (06:52 +0000)]
searchidxshard: rely on autoflush instead of ->flush

It reduces the number of ops and simplifies the code, slightly.
Add a missing IO::Handle import while we're at it, to be
explicit about which methods we use.

4 years agoconvert: remove unused variables capturing :from
Eric Wong [Sun, 2 Feb 2020 06:52:17 +0000 (06:52 +0000)]
convert: remove unused variables capturing :from

Looking at git history, they were never used.

4 years agov2writable: do not clobber {shards} or {parallel} if unset
Eric Wong [Sun, 2 Feb 2020 06:52:16 +0000 (06:52 +0000)]
v2writable: do not clobber {shards} or {parallel} if unset

The $jobs parameter in `public-inbox-convert' is passed to
V2Writable->init_inbox as `undef' by default, causing
parallelization to be disabled.

Instead, leave the underlying {parallel} flag untouched if
$shards is undef and do not clobber the default shard count.

This allows us to take advantage of multicore systems when
running public-inbox-convert with no command-line switches.

4 years agov2writable: nproc_shards: subtract 1 from given value
Eric Wong [Sun, 2 Feb 2020 06:52:15 +0000 (06:52 +0000)]
v2writable: nproc_shards: subtract 1 from given value

This is to be consistent with the `nproc(1)' code path.  It also
quiets down a warning from Admin when "-j $JOBS" is specified,
since the master process (which distributes work to shards and
handles OverIdx and Msgmap) is considered a job on its own.

4 years agot/multi-mid.t: extra test for -convert highwater mark
Eric Wong [Sun, 2 Feb 2020 06:52:14 +0000 (06:52 +0000)]
t/multi-mid.t: extra test for -convert highwater mark

This is derived from a real-world test case where I encounterd
multiple Message-IDs in a v1 inbox causing regen problems.

Fixes: eea47b676127bcdb ("convert: preserve highwater mark from v1 msgmap")
4 years agodoc: more 1.3.0 release notes updates
Eric Wong [Fri, 31 Jan 2020 23:45:18 +0000 (23:45 +0000)]
doc: more 1.3.0 release notes updates

Some updates with recent bugfixes and a few wording/formatting
improvements.

4 years agoconfig: assume multiple cgit URLs, too
Eric Wong [Sat, 1 Feb 2020 09:12:15 +0000 (09:12 +0000)]
config: assume multiple cgit URLs, too

Since we support inboxes with multiple URLs and multiple
infourls to reduce reliance on SPOFs, we'll do the same with
cgit URLs.

4 years agosolver: join multiple URLs with "||"
Eric Wong [Sat, 1 Feb 2020 09:12:14 +0000 (09:12 +0000)]
solver: join multiple URLs with "||"

It seems to make sense to the target audience that any of
the URLs displayed could work.

4 years agowwwtext: give "url" examples in sample config
Eric Wong [Sat, 1 Feb 2020 09:12:13 +0000 (09:12 +0000)]
wwwtext: give "url" examples in sample config

inbox.$NAME.url is a common parameter and set by
public-inbox-init(1), so ensure we have lines for it and
emphasize it can be multi-value for .onion hidden services or
otherwise mirrored and available under multiple URLs.

4 years agowwwtext: show multiple infourl values properly
Eric Wong [Sat, 1 Feb 2020 09:12:12 +0000 (09:12 +0000)]
wwwtext: show multiple infourl values properly

This is now an array, so ensure it's shown properly in the
sample config, instead of "ARRAY(0xI8BADBEEF)" or similar.

Fixes: 1988d730c0088e8b "config: support multi-value inbox.*.*url"
4 years agoconvert: preserve highwater mark from v1 msgmap
Eric Wong [Thu, 30 Jan 2020 07:51:06 +0000 (07:51 +0000)]
convert: preserve highwater mark from v1 msgmap

If we're reusing the msgmap from a v1 inbox, we also need to
ensure the highwater mark doesn't get doubled in the v1->v2
conversion by internally triggering the equivalent of
"--reindex" on a fresh v2 inbox.

This was needed to convert an indexed v1 inbox which featured
messages with multiple Message-IDs in it.  Fresh, unindexed
clones of v1 inboxes would not have been affected by this.

4 years agomboxgz: ensure gzipped mboxes always have filenames
Eric Wong [Thu, 30 Jan 2020 09:19:06 +0000 (09:19 +0000)]
mboxgz: ensure gzipped mboxes always have filenames

Lets always have Content-Disposition for files intended
to be downloaded for consumption by non-browsers, such
as pigz, zcat, "git am".

This is also to be consistent with the non-gzipped mbox
$MESSAGE_ID/raw endpoint.

4 years agot/psgi_search: test for subject-free messages
Eric Wong [Thu, 30 Jan 2020 09:19:05 +0000 (09:19 +0000)]
t/psgi_search: test for subject-free messages

Apparently I fixed this bug a while back in commit
f94c3a195a25a31d0215cd175938008fca473378 but did
not write tests.

4 years agov2writable: newest epochs go first in alternates
Eric Wong [Sun, 26 Jan 2020 23:41:02 +0000 (23:41 +0000)]
v2writable: newest epochs go first in alternates

New epochs are the most likely to have loose objects.  git won't
be able to take advantage of pack indices and needs to scan
every alternate for the loose object via open/openat syscalls.
Those syscalls will add up some day when we've got hundreds or
thousands of epochs.

4 years agoINSTALL: fix Linux::Inotify2 package name
Eric Wong [Tue, 28 Jan 2020 02:23:03 +0000 (02:23 +0000)]
INSTALL: fix Linux::Inotify2 package name

The "2" is important, since "Linux::Inotify" without the "2"
is not available from Debian 9/10 or CentOS 7.x and seems
unmaintained.

4 years agot/v2reindex.t: 5.10.1 glob compatibility
Eric Wong [Sun, 26 Jan 2020 10:29:24 +0000 (10:29 +0000)]
t/v2reindex.t: 5.10.1 glob compatibility

I'm not sure when `for (<"quoted string/glob/*">)' became
supported, and maybe it was inadvertant, but it fails
with Perl 5.10.1.  Just use the glob() function to be
explicit.

4 years agot/hl_mod: document IO::Handle for autoflush
Eric Wong [Sun, 26 Jan 2020 10:29:23 +0000 (10:29 +0000)]
t/hl_mod: document IO::Handle for autoflush

We don't need IO::File for this test, but IO::Handle
is needed for ->autoflush with Perl <5.14.

Note: I haven't tested highlight.pm under 5.10.1 since
it's a weird dependency which isn't easy to install w/o
distro support.

4 years agoavoid relying on IO::Handle/IO::File autoload
Eric Wong [Sun, 26 Jan 2020 10:29:22 +0000 (10:29 +0000)]
avoid relying on IO::Handle/IO::File autoload

Perl 5.14+ gained the ability to autoload IO::File
(and IO::Handle) on missing methods, so relying on
this breaks under 5.10.1.

There's no reason to load IO::File or IO::Handle
when built-in perlops work fine and are even a hair
faster.

4 years agodaemon: provide TCP_DEFER_ACCEPT for Perl <5.14
Eric Wong [Sun, 26 Jan 2020 10:29:21 +0000 (10:29 +0000)]
daemon: provide TCP_DEFER_ACCEPT for Perl <5.14

Socket::TCP_DEFER_ACCEPT() did not appear in the Socket module
distributed with Perl until 5.14, despite it being available
since Linux 2.4.

4 years agoviewdiff: rewrite and simplify
Eric Wong [Sat, 25 Jan 2020 04:45:10 +0000 (04:45 +0000)]
viewdiff: rewrite and simplify

Instead of going line-by-line, use split() with a giant regexp
to capture groups of contiguous lines.  This offloads state
management to the regexp itself and makes it FAR easier to
keep track of <span> and </span> pairings.

Performance seems roughly on par after this change for the
meta@public-inbox archives.  It seems a tiny bit faster for
git@vger with xt/perf-msgview.t, likely due to the longer
messages and larger contiguous groups of lines having the same
prefix (or no prefix at all) and drastically reduces the number
of subroutine calls and Perl ops executed.