about summary refs log tree commit homepage
DateCommit message (Collapse)
2021-02-24www: use PublicInbox::WwwStream
This prevents the following problem logged to the webserver's error log: E: Undefined subroutine &PublicInbox::WwwStream::code_footer called at /usr/share/perl5/PublicInbox/WwwListing.pm line 102. in PublicInbox::ConfigIter=ARRAY(0x557aea68b1a8)::each_section at /usr/share/perl5/PublicInbox/ConfigIter.pm line 37. Fixes: 7a3946ef122e ("www: support listing of inboxes")
2021-02-23lei_to_mail: remove unused OnDestroy import
2021-02-23lei q: reduce default lei2mail workers
While disk I/O is typically buffered for good scheduling, git blob decoding uses a non-trivial amount of CPU time and it helps to leave some CPU available for it.
2021-02-23lei: support "-C" to chdir in all sub commands
We'll also support "-C" at the end of most commands to give users a little more flexibility when building command-lines. This conflicts with "lei daemon-kill -CHLD", so that's special-cased since "-C" makes no sense with daemon-kill, anyways. Unlike "git show", the to-be-implemented "lei show" will diverge and enable "--find-copies[=<n>]" by default, so "-C[<n>]" won't be necessary.
2021-02-23doc: lei: favor "-o format:$PATHNAME" over "-f"
The --format argument is redundant and may be dropped entirely. Update the lei manpages to prefer the format prefix. cf. https://public-inbox.org/meta/20210217044032.GA17934@dcvr/
2021-02-22lei_auth: trim and remove leftover worker code
LeiAuth is no longer a separate worker process. Instead, it's used directly by LeiToMail and LeiImport for sharing auth info from the first worker to the rest of the workers, using lei-daemon as a message router. So drop the old code to reduce human cognitive load and interpreter memory overhead.
2021-02-22lei convert: inline convert_start
Since we stopped using LeiAuth as a WQ worker, keeping this around as a single-use sub makes no sense and wastes several KB of memory.
2021-02-22net_reader: mic_get: reuse connections if cache enabled
We only enable {mic_cached} in WQ workers, and those aren't expected to fork again going forward. So cache here avoid a penalty for the non-augmenting (imap_delete_all) call with "lei q"
2021-02-22lei q: reduce wasted IMAP connection for auth
We can rework the first lei2mail worker to authenticate, and then share auth info with the rest of the lei2mail workers. As with "lei import", this uses PktOp and lei-daemon to share updated credentials between the first an subsequent l2m workers.
2021-02-22lei_auth: migrate common auth code from lei_import
lei_to_mail will be able to use this, too.
2021-02-22lei import: no separate auth worker
We'll start sharing auth info from the first worker to the rest of the workers via wq_broadcast. This lays the groundwork for getting rid of LeiAuth workers for authentication work and reducing network round trips required for IMAP.
2021-02-22lei convert: auth directly from worker process
Since this only has one worker, we can auth directly in the worker since the convert worker now has access to the script/lei {sock} for running "git credential".
2021-02-22lei: _lei_cfg: return empty hashref if unconfigured
Existing callers in LeiExternal actually depend on this, and LeiAuth shouldn't need to be creating a config file just to do a conversion against an anonymous IMAP server.
2021-02-22lei: keep client {sock} in short-lived workers
For non-persistent workers, there's no harm in keeping the client socket open. This means we can avoid dancing around closing it in PublicInbox::LeiAuth::ipc_atfork_child. Eventually, other WQ workers will trigger "git credential" spawning in script/lei directly.
2021-02-22lei_auth: rename {nrd} field to {net} for clarity
We're authing for both reads and writes, this makes it clear that we support both NetReader and NetWriter.
2021-02-22lei_store: populate ALL.git/alternates with new epochs
Since eidx_init updates ALL.git/objects/info/alternates, we need to ensure new epochs we create from LeiStore->importer exist before eidx_init writes alternates. Reported-by: Kyle Meyer <kyle@kyleam.com> Link: https://public-inbox.org/meta/8735xou0gq.fsf@kyleam.com/
2021-02-22t/lei*: drop $lei->(...) sub
lei() and lei_ok() are superior since they offer prototype checks and lei_ok() adds another check + description DRY-ness. The $lei sub was only bound to a variable since it was in t/lei.t and named subs don't work well with the key2sub() wrapper.
2021-02-22lei-daemon: prefer graceful shutdowns
We'll keep the daemon alive as long as a a script/lei client remains connected. This ought to improve user experience and is in line with what -imapd/-httpd/-nntpd users have expected over the years.
2021-02-22tests: clean up t/home* consistently
And update t/home2/README while we're at it. Followup-to: 4ea3975dbed0a533 ("tests: setup_public_inboxes: use IMAP-friendly newsgroups")
2021-02-21t/www_listing: require grok-pull version 2 or later
The grok-pull-based tests in www_listing are incompatible with Grokmirror v2 in two ways: the generated configuration format and the expected exit codes. Update the tests to work with v2, and skip them for earlier versions. This was tested with the latest release of Grokmirror, v2.0.7. Note that the "pull" and "fsck" sections are required even though they're empty.
2021-02-21t/www_listing: reword grok-pull skip message
Make it clear that this skip is because grok-pull isn't available at all because the next commit will add another skip for older versions of Grokmirror.
2021-02-21t/www_listing: correct the number of tests for grok-pull skip
2021-02-21lei2mail: parallel augment for lock-free stores
This lets us make use of multiple cores on IMAP and Maildir backed by SSD (or better) storage. This benefits IMAP stores with high network latency, but may still penalize IMAP servers with rotational storage.
2021-02-21net_reader: use and accept URIimap objects in more places
This flexibility should save us some code down-the-line.
2021-02-21ipc: support setting a locked number of WQ workers
We can use this to ensure sharded work doesn't do unexpected things if workers are added/removed. We currently don't increase/decrease workers once a workqueue is started, but non-lei code (-httpd/imapd) may start doing so. This also fixes a bug where lei2mail workers could not be adjusted via --jobs on the command-line.
2021-02-21lei q: move augment into lei2mail workers
This is a step which will allow us to parallelize augment on Maildir and IMAP.
2021-02-21ipc: add wq_broadcast
We'll give workqueues a broadcast mechanism to ensure all workers see a certain message. We'll also tag each worker with {-wq_worker_nr} in preparation for work distribution. This is intended to avoid extra connection and fork() costs from LeiAuth in a future commit.
2021-02-21lei q: support IMAP/IMAPS --output destinations
Augment (and dedupe) aren't parallel, yet, so its more sensitive to high-latency networks.
2021-02-21inbox_writable: require PublicInbox::MdirReader
This wasn't causing known failures, but maybe it was or will in the future.
2021-02-19t/net_reader-imap: fix under TEST_RUN_MODE=0
PublicInbox::Config isn't loaded elsewhere by this file.
2021-02-19URIimap: overload "" to ->as_string
This interpolation is used by the upstream URI package and we rely on it elsewhere for HTTP(S) URIs, so save ourselves some surprises down the line.
2021-02-19net_writer: start implementing IMAP write support
Requiring TEST_IMAP_WRITE_URL to be set to a writable IMAP server URL isn't ideal, but it works for now until we have time to setup a mock dovecot/cyrus/etc... instance for testing.
2021-02-19net_reader: handle single-message IMAP mailboxes
Due to an off-by-one error, we were unable to read mailboxes with only a single message of UID:1. Without this fix, the message with UID:1 could only be read after UID:2 was created; so there's no permanent data loss as long as a new message showed up. This affects all releases of public-inbox-watch with IMAP support, though it probably went unnoticed because single message inboxes are rare.
2021-02-19tests: require Mail::IMAPClient for IMAP tests
All of our current IMAP code relies on Mail::IMAPClient at the moment, so ensure we skip those tests on systems without that module.
2021-02-19lei_to_mail: get rid of empty _post_augment_maildir
We won't have _post_augment_imap when we add IMAP support, either. _pre_augment_imap will not exist, either, since opening an IMAP(S) connection can be time consuming so we'll roll that into imap_common_init.
2021-02-19t/lei-externals: favor "-o format:$PATHNAME" over "-f"
It'll be less ambiguous for inputs with "lei convert" and "lei import" cf. https://public-inbox.org/meta/20210217044032.GA17934@dcvr/
2021-02-19emergency: modernize and reduce syscalls
As with LeiToMail, we'll exclusively rely on O_EXCL and EEXIST instead of "-f" (stat(2)) for file name collision checking. Furthermore, we can rely on link(2) error handling instead of using stat(2) to check the result of link(2). We'll still keep the hostname in these filenames, but memoize it on a per-instance basis since hostname changes are rare and we can assume it won't change between "tmp" and "cur". We'll also start embedding the PID as {"tmp.$$"} into the fiel name to guard against accidental deletion in child processes, instead of requiring an extra hash lookup. Finally, avoid multiple getpid(2) syscalls in internal subs since glibc no longer caches in getpid(3). We'll also favor constant comparison of $! against EEXIST for inlining. and stop doing ->autoflush when we only have a single print + flush.
2021-02-19lei_to_mail: Maildir: ensure link(2) succeeds
link(2) may fail with errors other than EEXIST; just bail out since something is likely seriously wrong.
2021-02-18lei: check for IMAP auth errors
We need to ensure authentication failures and error codes get propagated to the parent process(es) properly. v2: update MANIFEST v3: LeiAuth.pm ->_lei_cfg bit moved to a previous commit
2021-02-18lei: consolidate the bulk of the IPC code
The backends for "lei add-external --mirror", "lei convert", and "lei import" all share a similar pattern for spawning background workers. Hoist out the common parts to slim down our code base a bit. The LeiXSearch and LeiToMail workers for "lei q" remains a the odd duck due to the deep pipelining and parallelization.
2021-02-18lei import: add IMAP and (maildir|mbox*):$PATHNAME support
This makes "lei import" more similar to "lei convert" and allows importing from disparate sources simultaneously. We'll also fix some ->child_error usage errors and make the style of the code more similar to the "lei convert" code. v2: fix missing requires
2021-02-18lei convert: mail format conversion sub-command
This will make testing IMAP support for other commands easier, as it doesn't write to lei/store at all. Like the pager and MUA, "git credential" is always spawned by script/lei (and not lei-daemon) so it has a controlling terminal for password prompts. v2: fix missing requires, correct test ordering v3: ensure config exists for IMAP auth
2021-02-18lei: completion: bash: generalize nospace usage
We'll be completing more options with ':', '//' and '=' in the future, so make it easier to disable trailing spaces on completions.
2021-02-18t/lei_to_mail: remove unnecessary arg passing
{zpipe} is contained entirely within the $l2m object, now.
2021-02-18tests: setup_public_inboxes: use IMAP-friendly newsgroups
-imapd won't support newsgroups ending with /\.[0-9]+\z/ since it reserves those for partitioning inboxes into 50K slices. So bump the home[0-9]+ version and switch to IMAP-friendly newsgroup names.
2021-02-18lei import: move check_input_format to lei
We'll be supporting "lei convert" in a future change; so it makes sense to share a common internal API for common error messages.
2021-02-18lei import: start rearranging code for IMAP support
More to come in a later commit; some error handling and failure modes will be trickier with IMAP due to authentication.
2021-02-18watch: connect to NNTP and IMAP in config order
This is hopefully less surprising to users when they're prompted for credentials.
2021-02-18watch: move imap_common_init to NetReader
We'll use this in LeiImport and likely other places.
2021-02-18lei: bless config
We'll be needing ->url_match from PublicInbox::Config