about summary refs log tree commit homepage
path: root/lib
DateCommit message (Collapse)
2021-10-22watch: remove redundant signal mask manipulation
The top-level daemon process already blocks all signals, so there's no reason to block them around fork() calls.
2021-10-22watch: check for {quit} before IDLE
This may make it less likely for watch-dependent tests to get stuck. Unfortunately, due to the synchronous API of Mail::IMAPClient, ->idle is still susceptible to missing signals.
2021-10-22lei_search: try harder to associate "lei index"-ed messages
Allow checking for keyword changes if we have an known OID, even if the blob isn't currently reachable.
2021-10-22lei note-event: wq_io_do => wq_do
No need to pass extra arrayref args, here.
2021-10-22lei note-event: drop unnecessary eval guard
We don't want to lose the failure message in case note-event fails.
2021-10-22lei/store: check for any unexpected process death
The lei/store process should only exit from EOF on the socket, so make sure we note any unintended signals
2021-10-20httpd: reject requests with spaces in header names
Malicious clients may attempt HTTP request smuggling this way. This doesn't affect our current code as we only look for exact matches, but it could affect other servers behind a to-be-implemented reverse proxy built around our -httpd. This doesn't affect users behind varnish at all, nor the HTTPS/HTTP reverse proxy I use (I don't know about nginx), but could be passed through by other reverse proxies. This change is only needed for HTTP::Parser::XS which most users probably use. Users of the pure Perl parser (via PLACK_HTTP_PARSER_PP=1) already hit 400 errors in this case, so this makes the common XS case consistent with the pure Perl case. cf. https://www.mozilla.org/en-US/security/advisories/mfsa2006-33/
2021-10-19lei_mail_sync: show non-matching SHA
It could prove useful for diagnosing bugs (either on our end or an MUA's), or storage device failures.
2021-10-19lei inspect: show ISO8601 {rt} and {dt}, too
While inspect is intended for debugging, the Unix epoch in seconds requires extra steps for human consumption; just steal what we used for "lei q -f json" output.
2021-10-19lei inspect: add atfork hook
This is necessary for in case an inspect command is run in a parallel with other commands.
2021-10-19lei: remove unused ->busy time arg
Our graceful shutdown doesn't time out clients.
2021-10-19lei up: support --exclude=, --no-(external|remote|local)
These can be used to temporarily disable using certain externals in case of temporary network failure or mount point unavailability.
2021-10-19lei: conditionally add "\n" to error messages
Some error messages already include "\n" (w/ file+line info), so don't add another one. (`warn' will automatically add its caller location unless there's a final "\n").
2021-10-19lei up: propagate redispatch_all failure via exit code
We can still continue with some local externals, maybe; but the error needs to be propagated to the calling process for scripting purposes.
2021-10-19lei: use die for external and query handling
This allows "lei up" to continue processing unrelated externals if on output fails.
2021-10-19lei up: prefix `remote' and `local' with `o_'
This will help distinguish between mail outputs and external public-inboxes.
2021-10-19test_common: lazy-require AutoReap
This might speed up non-daemon-using tests.
2021-10-18v2: mirrors don't clobber msgs w/ reused Message-IDs
For odd messages with reused Message-IDs, the second message showing up in a mirror (via git-fetch + -index) should never clobber an entry with a different blob in over. This is noticeable only if the messages arrive in-between indexing runs. Fixes: 4441a38481ed ("v2: index forwards (via `git log --reverse')")
2021-10-18extindex: show mismatches for messages deleted from inbox
There seems to be a bug in v2 inbox reindexing somewhere...
2021-10-17extindex: better locations for {quit} checks
Check for graceful termination at every message since it's a fairly inexpensive check.
2021-10-17extindex: guard against false mismatch unrefs
I'm not sure if this is a bug or not (or it could be an old bug in the v2 indexing code).
2021-10-17extindex: retry sync_inbox before reindex
Ensure the num highwater mark of the target inbox is stable before using it. Otherwise we may end up repeating work done to index a message.
2021-10-17extindex: use localtime to display lock time
Since this is intended for use on the command-line, include TZ offset in time and try to shorten the message a bit so it wraps less on a terminal.
2021-10-17msgmap: do not cache num_highwater
Caching the value doesn't seem necessary from a performance perspective, and it adds a caveat for read-only users which may lead to bugs in future code.
2021-10-16eml: fix leak workaround
Our previous workaround didn't actually work around the leak in <https://rt.cpan.org/Public/Bug/Display.html?id=139622> since croak()-via-Perl was still invoked before the SV reference count could be decremented. Put in a proper workaround which saves warnings onto a temporary variable and only croak after ->decode or ->encode returns; not inside those methods.
2021-10-16lei sockets: favor level-triggered epoll for fairness
Sigfd->event_step needs priority over script/lei clients, LeiSelfSocket, and everything else.
2021-10-16input_pipe: do not loop in ->event_step for fairness
Sigfd->event_step needs priority over InputPipe (and everything else). We keep Edge Triggering here but use ->requeue instead of looping inside event_step. This was necessary because InputPipe can be used with regular files which can't be monitored with epoll. We'll also rid of the vestigial lei-oneshot support while we're at it.
2021-10-16pkt_op: favor level-triggered epoll for fairness
Sigfd->event_step needs priority over PktOp (and everything else). We'll also add ECONNRESET checking, here, since it could see bidirectional use in the future. This is unlikely to have any sort of performance difference since this is only for small, occasional packets, but the code reduction is nice.
2021-10-16wqworker: favor level-triggered epoll for fairness
Sigfd->event_step needs priority over WQWorkers (and everything else). Do that by running once per event_loop iteration rather than looping inside event_step. This lowers throughput since it requires more syscalls, but that's the price of fairness.
2021-10-16extindex: avoid triggering a buggy unref
We can't attempt to unref messages beyond the highwater mark of an inbox. This bugfix was found by commit c485036d0b1ce7ed (extindex: guard against buggy unrefs, 2021-10-14), which actually did its intended job and guarded against a buggy unref.
2021-10-16httpd/async: switch to level-triggered epoll
We'll save ourselves some code here and let the kernel do more work, instead.
2021-10-16inbox + search: use 5.10.1 and do some golfing
Some yak-shaving while I try to track down other bugs...
2021-10-16lei_to_mail: quiet down abort messages
We don't need to flood the terminal with "W: $oid is (!= blob)\n" messages when somebody nukes a git cat-file process from under us.
2021-10-16lei_overview: die rather than lei->fail
This will make our code more flexible in case it gets used in non-lei things.
2021-10-16extindex: prune invalid alternate entries on --gc
Seeing the same warning over and over again gets annoying.
2021-10-16lei: more eval guards for die on failure
Relying on $lei->fail is unsustainable since there'll always be parts of our code and dependencies which can trigger die() and break the event loop.
2021-10-16lei: always keep cwd fd {3} for ->fchdir
The extra FD shouldn't cause noticeable overhead in short-lived workers, and it lets us simplify lei->rel2abs. Get rid of a 2-argument form of open() while we're at it, since it's been considered for warning+deprecation by Perl for safety reasons.
2021-10-16lei: golf PATH2CFG cleanup
More code means more bugs.
2021-10-16httpd: move pipeline logic into event_step
Most of the HTTP server code was written for Danga::Socket and not fully-transitioned to take advantage of PublicInbox::DS. This change brings it up-to-date with the style of pipeline handling used for -imapd and -nntpd.
2021-10-16imapd+nntpd: drop timer-based expiration
It's needlessly complex and O(n), so it doesn't scale well to a high number of clients nor is it easy-to-scale with the data structures available to us in pure Perl. In any case, I see no evidence of either -imapd nor -nntpd experiencing high connection loads on public-facing sites. -httpd has never had its own timer-based expiration, either. Fwiw, public-inbox.org itself has been running a public-facing HTTP/HTTPS server with no userspace idle client expiration for the past 8 years or with no ill effect. Clients can come and go as they wish, and SO_KEEPALIVE takes care of truly broken connections if they're gone for ~2 hours. Internet connections drop all time, so it should be harmless to drop connections w/o warning since both NNTP and IMAP protocols have well-defined semantics for determining if a message was truncated (as does HTTP/1.1+).
2021-10-16dir_idle: do not add watches in ->new
There's no savings in having two ways to add watches to an inotify nor kqueue descriptor.
2021-10-16smsg: add ->oidbin method
This makes some of our code less noisy by reducing the amount of pack('H*', ...) use.
2021-10-15lei q: guard query_done against die()
v2w->wq_do('done') may die on I/O errors, and likely other places. Just guard the entire block with an eval and ->fail as appropriate.
2021-10-15lei forget-search: support multiple args
I've been testing a lot of searches which I don't want to keep around, so make it easy to remove a bunch at once. We'll behave like rm(1) and keep going in the face of failure.
2021-10-15lei note-event: fix explicit flush reliability
We need to send the socket over to lei/store and wait for the kernel to drop the socket refcount down to zero before script/lei can exit. This is not a new bug and only caused very sporadic test failures. I only noticed it while simplifying IPC stuff.
2021-10-15lei + ipc: simplify process reaping
Simplify our APIs and force dwaitpid() to work in async mode for all lei workers. This avoids having lingering zombies for parallel searches if one worker finishes soon before another. The old distinction between "old" and "new" workers was needlessly complex, error-prone, and embarrasingly bad. We also never handled v2:// writers properly before on Ctrl-C/Ctrl-Z (SIGINT/SIGTSTP), so add them to @WQ_KEYS to ensure they get handled by $lei when appropropriate.
2021-10-15lei forget-search: fix for symlink-ed paths
If lei up and edit-search work on something, so should forget-search.
2021-10-15lei q: avoid kw lookup failure on remote mboxrd
When importing several sources in parallel via http(s) mboxrd, we need to be able to get keywords of uncommitted documents directly from shard workers. Otherwise, Xapian DocNotFound errors happen because the read-only LeiSearch won't see documents from uncomitted transactions. Keep in mind that it's possible the keywords can be changed on-the-fly even for uncommitted documents because of inotify watches from LeiNoteEvent.
2021-10-15www: various help text updates
`dt:' documentation is redundant with `d:' approxidate support; so drop `dt:' since mairix uses `d:'. We'll also document `rt:' since there are legit messages from senders with broken clocks. Reduce indentation level of help texts to be in 2-space increments to using too much horizontal space. We'll always place IMAP ahead of NNTP since it's alphabetical and there's likely more IMAP clients out there. Add "--ng NEWSGROUP" to -init instructions if configured. There's also some minor wording changes throughout.
2021-10-15lei up --all: send signals to workers, receive errors
The redispatch mechanism wasn't routing signals and messages between redispatched workers and script/lei properly. We now rely on PktOp to do bidirectional message forwarding and carefully avoiding circular references by using PktOp.