]> Sergey Matveev's repositories - public-inbox.git/log
public-inbox.git
4 years agotests: don't repeatly validate NEWS.atom
Eric Wong [Fri, 29 Nov 2019 10:14:12 +0000 (10:14 +0000)]
tests: don't repeatly validate NEWS.atom

We can create a stamp to avoid rerunning the check unless
NEWS.atom changes (and it will, soon, I hope :>).

4 years agoTODO: update and add a few more items
Eric Wong [Fri, 29 Nov 2019 10:14:11 +0000 (10:14 +0000)]
TODO: update and add a few more items

SpamAssassin has used re2c (via sa-compile) for many years, now,
and it seems to work fine, there.  GMime also looks promising
when combined with Inline::C since GMime can operate on mmap-ed
regions.

Given the inevitable demise of many .orgs when price rise;
supporting a URL rewriter similar to .mailmap makes sense.

And HTTP CONNECT seems like something our -httpd can support
to let firewalled users read over NNTP.

4 years agods: ->Reset initializes $nextq
Eric Wong [Fri, 29 Nov 2019 10:14:10 +0000 (10:14 +0000)]
ds: ->Reset initializes $nextq

I haven't noticed this being a problem in practice, but
be consistent with the rest of the singleton stuff.
Since we always call Reset() at load time, only do
initialization in that sub and not at declaration.

4 years agot/common: set $0 when running script w/o fork
Eric Wong [Fri, 29 Nov 2019 10:14:09 +0000 (10:14 +0000)]
t/common: set $0 when running script w/o fork

We can localize changes to $0 so $0 is restored when the
"script" sub is done.  This will be helpful when we encounter
a stuck/slow processes during our tests (hopefully never!)

4 years agot: localize the PI_CONFIG env
Eric Wong [Fri, 29 Nov 2019 10:14:08 +0000 (10:14 +0000)]
t: localize the PI_CONFIG env

We don't want the user's ~/.public-inbox/config to be read from
during tests.  I only noticed this because I had a non-existent
pathname for one of my inboxes :x

I've also verified this change by running "inotifywait
~/.public-inbox/config -m" in another terminal while running
"make check"; (perhaps a portable solution could make it
into the test suite).

4 years agoreplace: quiet "git gc" invocation
Eric Wong [Thu, 28 Nov 2019 20:54:35 +0000 (20:54 +0000)]
replace: quiet "git gc" invocation

Since we give users no indication or control of how "git gc"
runs, showing its progress is confusing.

4 years agot/replace: quiet "git fsck" invocation
Eric Wong [Thu, 28 Nov 2019 20:54:34 +0000 (20:54 +0000)]
t/replace: quiet "git fsck" invocation

Test output can be a terminal if running as "perl -I lib t/$FOO.t",
and showing fsck progress is pointless for tests.

4 years agot/httpd-unix: FreeBSD expects to fail with EADDRINUSE
Eric Wong [Thu, 28 Nov 2019 07:08:54 +0000 (07:08 +0000)]
t/httpd-unix: FreeBSD expects to fail with EADDRINUSE

Tested FreeBSD 11.2.  I'm starting to think I'm too conservative
with this check and it could be safely expanded to cover any OS
with UNIX sockets.

4 years agoMakefile.PL: MANIFEST dependency fix
Eric Wong [Wed, 27 Nov 2019 11:07:18 +0000 (11:07 +0000)]
Makefile.PL: MANIFEST dependency fix

We need to force an update to Makefile (not Makefile.PL) when
MANIFEST changes.  Since "Makefile" (aka. "$(FIRST_MAKEFILE)")
is already a single-colon make target; we can't create a
double-colon rule to augment it.  So we'll continue using a
"Makefile.PL" rule, but have it recreate the resulting Makefile

Finally, change the "check" target to use "prove -b" instead of
"prove -l" so we test against "blib/lib", since what's in the
"blib" dir will be installed.

Fixes: 4c20de0694d06ff3 ("Makefile.PL: add dependency on MANIFEST contents")
4 years agohttpd|nntpd: avoid missed signal wakeups
Eric Wong [Wed, 27 Nov 2019 01:33:33 +0000 (01:33 +0000)]
httpd|nntpd: avoid missed signal wakeups

Our attempt at using a self-pipe in signal handlers was
ineffective, since pure Perl code execution is deferred
and Perl doesn't use an internal self-pipe/eventfd.  In
retrospect, I actually prefer the simplicity of Perl in
this regard...

We can use sigprocmask() from Perl, so we can introduce
signalfd(2) and EVFILT_SIGNAL support on Linux and *BSD-based
systems, respectively.  These OS primitives allow us to avoid a
race where Perl checks for signals right before epoll_wait() or
kevent() puts the process to sleep.

The (few) systems nowadays without signalfd(2) or IO::KQueue
will now see wakeups every second to avoid missed signals.

4 years agodskqxs: fix missing EV_DISPATCH define
Eric Wong [Wed, 27 Nov 2019 01:33:32 +0000 (01:33 +0000)]
dskqxs: fix missing EV_DISPATCH define

Oops, IO::KQueue support was broken due to this missing
constant.  Add a new ds-kqxs.t test case to ensure we
test the IO::KQueue path if IO::KQueue is available.

4 years agomsgtime: deal with strange minutes in TZ offsets
Eric Wong [Mon, 25 Nov 2019 05:24:54 +0000 (05:24 +0000)]
msgtime: deal with strange minutes in TZ offsets

I'm not sure if TZ minute offsets aside from '00' or '30' exist,
but lets just deal with them properly when negative.  Examples
taken from various inboxes on lore.kernel.org.  These are mostly
message from spammers, but some are legitimate messages.

4 years agot/msgtime: add more checks for known cases
Eric Wong [Mon, 25 Nov 2019 05:24:53 +0000 (05:24 +0000)]
t/msgtime: add more checks for known cases

Broken email clients sent the darndest things, make sure
we can still support them when we make Date::Parse optional.

4 years agot/msgtime: show date in test descriptions
Eric Wong [Mon, 25 Nov 2019 05:24:52 +0000 (05:24 +0000)]
t/msgtime: show date in test descriptions

Otherwise it's hard to figure what fails.

4 years agotests: move giant inbox/git dependent tests to xt/
Eric Wong [Sun, 24 Nov 2019 00:22:37 +0000 (00:22 +0000)]
tests: move giant inbox/git dependent tests to xt/

xt/ is typically reserved for "eXtended tests" intended for
the maintainers and not ordinary users.  Since these require
special configuration and do nothing by waste cycles
during startup, they qualify.

4 years agot/perf-*.t: use $ENV{GIANT_INBOX_DIR} consistently
Eric Wong [Sun, 24 Nov 2019 00:22:36 +0000 (00:22 +0000)]
t/perf-*.t: use $ENV{GIANT_INBOX_DIR} consistently

It's more consistent with our current terminology and
"PI_DIR" is already used to override ~/.public-inbox/
(which holds "config" and possibly other files which affect
all inboxes for a particular user, but is not an inbox itself);
so stop advertising GIANT_PI_DIR in skip messages.

4 years agotests: quiet down commit graph
Eric Wong [Sun, 24 Nov 2019 00:22:35 +0000 (00:22 +0000)]
tests: quiet down commit graph

Newer versions of git enable the commit graph by default.
Since we blow away our temporary directories every test,
generating graphis is a waste and clutters stderr with
"Computing commit graph generation numbers" messages.

4 years agotests: use File::Temp->newdir instead of tempdir()
Eric Wong [Sun, 24 Nov 2019 00:22:34 +0000 (00:22 +0000)]
tests: use File::Temp->newdir instead of tempdir()

We'll also introduce a tmpdir() API to give tempdirs
consistent names.

4 years agoxapcmd: replace Xtmpdirs with File::Temp->newdir
Eric Wong [Sun, 24 Nov 2019 00:22:33 +0000 (00:22 +0000)]
xapcmd: replace Xtmpdirs with File::Temp->newdir

Since we're using Perl 5.10.1 and File::Temp 0.19+, we don't
need Xtmpdirs at all for cleaning up tempdirs on failure and
can just rely on the DESTROY handler provided by File::Temp.

4 years agot/nntpd-validate: get rid of threads dependency
Eric Wong [Sun, 24 Nov 2019 00:22:32 +0000 (00:22 +0000)]
t/nntpd-validate: get rid of threads dependency

Threads are officially discouraged by perl5-porters and proves
problematic with my Perl installation when using run_mode=1
to speed up tests.  So just use fork() and pipes to share
results from Net::NNTP.

4 years agot/common: start_script replaces spawn_listener
Eric Wong [Sun, 24 Nov 2019 00:22:31 +0000 (00:22 +0000)]
t/common: start_script replaces spawn_listener

We can shave several hundred milliseconds off tests which spawn
daemons by preloading and avoiding startup time for common
modules which are already loaded in the parent process.

This also gives ENV{TAIL} support to all tests which support
daemons which log to stdout/stderr.

4 years agodaemon: avoid race when quitting workers
Eric Wong [Sun, 24 Nov 2019 00:22:30 +0000 (00:22 +0000)]
daemon: avoid race when quitting workers

While the master process has a self-pipe to avoid missing
signals, worker processes lack that aside from a pipe to
detect master death.

That pipe doesn't exist when there's no master process,
so it's possible DS::close never finishes because it
never woke up from epoll_wait.  So create a pipe on
the worker_quit signal and force it into epoll/kevent
so it wakes up right away.

4 years agodaemon: use sigprocmask when respawning workers
Eric Wong [Sun, 24 Nov 2019 00:22:29 +0000 (00:22 +0000)]
daemon: use sigprocmask when respawning workers

We need to block signals in workers during respawns
until they're ready to receive signals.

4 years agodaemon: use sigprocmask to block signals at startup
Eric Wong [Sun, 24 Nov 2019 00:22:28 +0000 (00:22 +0000)]
daemon: use sigprocmask to block signals at startup

`$SIG{FOO} = "IGNORE"' will cause the daemon to miss signals
entirely.  Instead, we can use sigprocmask to block signal
delivery until we have our signal handlers setup.  This closes a
race where a PID file can be written for an init script and a
signal to be dropped via "IGNORE".

4 years ago.gitignore: ignore local prove(1) files
Eric Wong [Sun, 24 Nov 2019 00:22:27 +0000 (00:22 +0000)]
.gitignore: ignore local prove(1) files

As described in prove(1), .prove is storage for --state=save
and .proverc allows per-worktree customizations.

4 years agot/nntpd-tls: sometimes SSL_connect succeeds quickly
Eric Wong [Sun, 24 Nov 2019 00:22:26 +0000 (00:22 +0000)]
t/nntpd-tls: sometimes SSL_connect succeeds quickly

It seems caching can happen within OpenSSL or negotiation
can be delayed in some cases.  In any case, don't barf on
PublicInbox::TLS::epollbit() when connect_SSL succeeds
unexpectedly.

4 years agot/httpd-corner: wait for worker process death
Eric Wong [Sun, 24 Nov 2019 00:22:25 +0000 (00:22 +0000)]
t/httpd-corner: wait for worker process death

We need to ensure the worker process is terminated before
starting a new connection, so leave a persistent HTTP/1.1
connection open and wait for the SIGKILL to take effect
and drop the client.

4 years agot/xcpdb-reshard: test xcpdb --compact
Eric Wong [Sun, 24 Nov 2019 00:22:24 +0000 (00:22 +0000)]
t/xcpdb-reshard: test xcpdb --compact

We did not have a test for this, and need to guard against
regressions when changing Xapcmd to use File::Temp->newdir
in future commits.

4 years agot/v1-add-remove-add: quiet down "git init"
Eric Wong [Sun, 24 Nov 2019 00:22:23 +0000 (00:22 +0000)]
t/v1-add-remove-add: quiet down "git init"

Use the "-q" flag like everywhere else.

4 years agotests: use strict everywhere
Eric Wong [Sun, 24 Nov 2019 00:22:22 +0000 (00:22 +0000)]
tests: use strict everywhere

The "strict" pragma makes code easier to debug, and we had
undeclared variables as a result in t/watch_maildir_v2.t.
So use it everywhere to be consistent with the rest of our
code.

4 years agotests: disable daemon workers in a few more places
Eric Wong [Sun, 24 Nov 2019 00:22:21 +0000 (00:22 +0000)]
tests: disable daemon workers in a few more places

There were still a few places where we used worker processes
unnecessarily in tests, causing a small amount of unnecessary
overhead.

Followup-to: ad221e9b2852f6c5 ("t/*.t: disable nntpd/httpd worker processes in most tests")
4 years agomboxgz: fix compiler parse error under under Perl 5.16.3
Eric Wong [Sun, 24 Nov 2019 03:19:42 +0000 (03:19 +0000)]
mboxgz: fix compiler parse error under under Perl 5.16.3

Perl 5.16.3 (and possibly older versions) fails with the
following errors (from CentOS7):

  Use of ?PATTERN? without explicit operator is deprecated
  Search pattern not terminated

4 years agocheck for File::Temp 0.19 for ->newdir method
Eric Wong [Sun, 24 Nov 2019 03:12:37 +0000 (03:12 +0000)]
check for File::Temp 0.19 for ->newdir method

This is distributed with Perl 5.10.1 and onwards, so it should
not be an installation burden for any users.  I'm planning to
move away from tempdir() entirely and use File::Temp->newdir to
remove dependencies on END{} blocks.

4 years agot/xcpdb-reshard: use run_script for -xcpdb
Eric Wong [Fri, 15 Nov 2019 09:50:59 +0000 (09:50 +0000)]
t/xcpdb-reshard: use run_script for -xcpdb

This more than doubles the speed of the test, since we make
many invocations of -xcpdb.

4 years agot/indexlevels-mirror*: switch to run_script
Eric Wong [Fri, 15 Nov 2019 09:50:58 +0000 (09:50 +0000)]
t/indexlevels-mirror*: switch to run_script

This more than doubles the speed of these tests

4 years agot/v2mda: switch to run_script in many places
Eric Wong [Fri, 15 Nov 2019 09:50:57 +0000 (09:50 +0000)]
t/v2mda: switch to run_script in many places

This more than doubles the speed of the test.

4 years agot/watch_filter_rubylang: run_script for -init and -index
Eric Wong [Fri, 15 Nov 2019 09:50:56 +0000 (09:50 +0000)]
t/watch_filter_rubylang: run_script for -init and -index

This nets us a 20% speedup or so.

4 years agot/nntpd: use run_script for -init
Eric Wong [Fri, 15 Nov 2019 09:50:55 +0000 (09:50 +0000)]
t/nntpd: use run_script for -init

This only gives a 5% speedup or so, but anything helps.

4 years agot/watch_maildir_v2: use run_script for -init
Eric Wong [Fri, 15 Nov 2019 09:50:54 +0000 (09:50 +0000)]
t/watch_maildir_v2: use run_script for -init

This only gives a small 10% speedup or so, but anything helps.

4 years agot/httpd: use run_script for -init
Eric Wong [Fri, 15 Nov 2019 09:50:53 +0000 (09:50 +0000)]
t/httpd: use run_script for -init

This only gives a small ~10% speedup, since -httpd still
needs execve, but any speedup is welcome.

4 years agot/convert-compact: convert to run_script
Eric Wong [Fri, 15 Nov 2019 09:50:52 +0000 (09:50 +0000)]
t/convert-compact: convert to run_script

While this didn't use IPC::Run, having to reload several Perl
modules and scripts is slow and inefficient, so roughly
double the speed of this test.

4 years agot/v2mirror: switch to default run_mode for speedup
Eric Wong [Fri, 15 Nov 2019 09:50:51 +0000 (09:50 +0000)]
t/v2mirror: switch to default run_mode for speedup

We need to be careful and explicitly close FDs before doing
-index, since we can't rely on FD_CLOEXEC without execve(2)
syscalls.

4 years agodoc: remove IPC::Run as a dev and test dependency
Eric Wong [Fri, 15 Nov 2019 09:50:50 +0000 (09:50 +0000)]
doc: remove IPC::Run as a dev and test dependency

It's no longer needed and we're able to speed up some
of our tests as a result.

4 years agot/mda_filter_rubylang: drop IPC::Run dependency
Eric Wong [Fri, 15 Nov 2019 09:50:49 +0000 (09:50 +0000)]
t/mda_filter_rubylang: drop IPC::Run dependency

This test runs more than twice as fast, now.

4 years agot/mda: switch to run_script for testing
Eric Wong [Fri, 15 Nov 2019 09:50:48 +0000 (09:50 +0000)]
t/mda: switch to run_script for testing

Another noticeable speedup, this test is roughly ~3x faster now.

4 years agot/v2mirror: get rid of IPC::Run dependency
Eric Wong [Fri, 15 Nov 2019 09:50:47 +0000 (09:50 +0000)]
t/v2mirror: get rid of IPC::Run dependency

Not taking advantage of faster run modes in run_script, yet
since some lifetime problems need to be sorted.

4 years agot/purge: convert to run_script
Eric Wong [Fri, 15 Nov 2019 09:50:46 +0000 (09:50 +0000)]
t/purge: convert to run_script

This nets us another sizeable speedup.

4 years agot/init: convert to using run_script
Eric Wong [Fri, 15 Nov 2019 09:50:45 +0000 (09:50 +0000)]
t/init: convert to using run_script

This gives a 2-3x speedup on the test with the default
run_mode=1.

4 years agot/edit: switch to use run_script
Eric Wong [Fri, 15 Nov 2019 09:50:44 +0000 (09:50 +0000)]
t/edit: switch to use run_script

Perl parsing is slow, and run_script default behavior allows
this to speed up t/edit.t by over 100% in my case.

4 years agot/common: introduce run_script wrapper for t/cgi.t
Eric Wong [Fri, 15 Nov 2019 09:50:43 +0000 (09:50 +0000)]
t/common: introduce run_script wrapper for t/cgi.t

This will give us a consistent interface for running
test scripts in more performant ways while still giving
us a consistent interface to recreate real-world behavior
via spawn() (fork + execve), if needed.

The default run_mode (1) is faster and can run within the test
process with some minor adjustments to our code to avoid global
state.

This avoids the significante overhead of Perl code loading,
parsing and compilation phases.

4 years agospawn: which: allow embedded slash for relative path
Eric Wong [Fri, 15 Nov 2019 09:50:42 +0000 (09:50 +0000)]
spawn: which: allow embedded slash for relative path

This makes the subroutine behave more like which(1) command
and will make using spawn() in tests easier.

4 years agoxapcmd: do not fire END and DESTROY handlers in child
Eric Wong [Fri, 15 Nov 2019 09:50:41 +0000 (09:50 +0000)]
xapcmd: do not fire END and DESTROY handlers in child

We need to bypass whatever Test::More does with END/DESTROY
handlers for use in lon-lived process.  This doesn't affect
any of our normal code since we don't use END/DESTROY for
Xapcmd and its callers.

4 years agoimport: only pass Inbox object to SearchIdx->new
Eric Wong [Fri, 15 Nov 2019 09:50:40 +0000 (09:50 +0000)]
import: only pass Inbox object to SearchIdx->new

SearchIdx->new no longer accepts a GIT_DIR path as its argument
since commit 585314673236d664729fe3ab2d4fb229d1c0f2d5
("searchidx: require PublicInbox::Inbox (or InboxWritable) ref")

4 years agoinboxwritable: add ->cleanup method
Eric Wong [Fri, 15 Nov 2019 09:50:39 +0000 (09:50 +0000)]
inboxwritable: add ->cleanup method

We've been using this in -edit, and will be using it in some
more scripts and tests to optimize for run_mode=2 with
run_script.

Keeping this in the *Writable modules since I don't see it being
useful for the WWW and NNTP read-only interfaces which use
PublicInbox::Inbox.

4 years agolearn: pass global variables into subs
Eric Wong [Fri, 15 Nov 2019 09:50:38 +0000 (09:50 +0000)]
learn: pass global variables into subs

Avoid 'Variable "%s" will not stay shared' warnings
when the contents of this script eval'ed into a sub.

4 years agomda: pass global variables into subs
Eric Wong [Fri, 15 Nov 2019 09:50:37 +0000 (09:50 +0000)]
mda: pass global variables into subs

Avoid 'Variable "%s" will not stay shared' warnings
when the contents of this script eval'ed into a sub.

4 years agoinit: pass global variables into subs
Eric Wong [Fri, 15 Nov 2019 09:50:36 +0000 (09:50 +0000)]
init: pass global variables into subs

Avoid 'Variable "%s" will not stay shared' warnings
when the contents of this script eval'ed into a sub.

We also need to rely on ->DESTROY instead of END{}
to unlink the lock file on sub exit.

4 years agoindex: pass global variables into subs
Eric Wong [Fri, 15 Nov 2019 09:50:35 +0000 (09:50 +0000)]
index: pass global variables into subs

Avoid 'Variable "%s" will not stay shared' warnings
when the contents of this script eval'ed into a sub.

4 years agoadmin: get rid of singleton $CFG var
Eric Wong [Fri, 15 Nov 2019 09:50:34 +0000 (09:50 +0000)]
admin: get rid of singleton $CFG var

PublicInbox::Admin::config() just adds an extra layer of
indirection which we barely rely on.  So get rid of this
global variable and make it easier to run tests in the
future without relying on global state.

4 years agoedit: use OO API of File::Temp to shorten lifetime
Eric Wong [Fri, 15 Nov 2019 09:50:33 +0000 (09:50 +0000)]
edit: use OO API of File::Temp to shorten lifetime

Instead of relying on END{} blocks, rely on ->DESTROY
so the temporary files go out-of-scope and system
resources get released, sooner.

4 years agoedit: pass global variables into subs
Eric Wong [Fri, 15 Nov 2019 09:50:32 +0000 (09:50 +0000)]
edit: pass global variables into subs

Avoid 'Variable "%s" will not stay shared' warnings
when the contents of this script eval'ed into a sub.

4 years agomboxgz: use Compress::Raw::Zlib instead of IO::Compress::Gzip
Eric Wong [Sat, 16 Nov 2019 02:34:39 +0000 (02:34 +0000)]
mboxgz: use Compress::Raw::Zlib instead of IO::Compress::Gzip

IO::Compress::Gzip is a wrapper around Compress::Raw::Zlib,
anyways, and being able to easily detach buffers to return them
via ->getline is nice.  This results in a 1-2% performance
improvement when fetching giant mboxes.

4 years agombox: split mboxgz out into a separate file
Eric Wong [Sat, 16 Nov 2019 02:34:38 +0000 (02:34 +0000)]
mbox: split mboxgz out into a separate file

It'll make using Compress::Raw::Zlib easier, since we
can use that and import constants more easily.

4 years agombox: unused mid_clean import
Eric Wong [Sat, 16 Nov 2019 02:34:37 +0000 (02:34 +0000)]
mbox: unused mid_clean import

We're gradually phasing mid_clean out (in favor of mids()).

4 years agodoc: check-man: save the result of successful runs
Eric Wong [Thu, 14 Nov 2019 06:41:14 +0000 (06:41 +0000)]
doc: check-man: save the result of successful runs

We can keep a stamp around if the corresponding manpage hasn't
changed to avoid re-running man(1) and awk(1).

4 years agot/psgi_mount: require SearchIdx before using
Eric Wong [Thu, 14 Nov 2019 06:41:13 +0000 (06:41 +0000)]
t/psgi_mount: require SearchIdx before using

We may not implicitly load it via other means in the future.

4 years agot/common: move unix_server to t/httpd-corner.t
Eric Wong [Thu, 14 Nov 2019 06:41:12 +0000 (06:41 +0000)]
t/common: move unix_server to t/httpd-corner.t

unix_server() is not commonly used, only t/httpd-corner.t uses
it and most HTTP tests use TCP since most HTTP libraries only
support TCP.

4 years agot/common: inline stream_to_string into t/feed.t
Eric Wong [Thu, 14 Nov 2019 06:41:11 +0000 (06:41 +0000)]
t/common: inline stream_to_string into t/feed.t

We only use it in one place and have favored test_psgi
in newer tests, so move it out-of-the-way to reduce startup
overhead of other *.t files.

4 years agodoc: mknews: support Email::MIME <1.930
Eric Wong [Thu, 14 Nov 2019 10:57:32 +0000 (10:57 +0000)]
doc: mknews: support Email::MIME <1.930

Email::MIME::header_str is not available until 1.930, so the
rest of our code uses Email::MIME::header for compatibility
with distros, since CentOS 7.x only has 1.926.

4 years agoconvert: remove duplicated GetOptions() call
Eric Wong [Thu, 14 Nov 2019 08:47:40 +0000 (08:47 +0000)]
convert: remove duplicated GetOptions() call

We only need to parse the command-line once.

4 years agoinboxwritable: drop {-importer} cyclic reference
Eric Wong [Thu, 14 Nov 2019 01:12:11 +0000 (01:12 +0000)]
inboxwritable: drop {-importer} cyclic reference

InboxWritable caching the result of ->importer leads to a
circular references with returned (V2Writable|Import) object
holds onto the calling InboxWritable object.

With public-inbox-watch, this leads to a memory leak if a user
is reloading via SIGHUP after a message is imported (it would
only become noticeable with SIGHUPs after every message imported).

I would not expect anybody to to notice this in real-world
usage.  I only noticed this since I was making -xcpdb suitable
for long-lived process use (e.g. "mod_perl style") and a flock
remained unreleased on v1 inboxes after resharding.

WatchMaildir (used by -watch) already handles caching of the
importer object itself, and all of our other real-world uses of
->importer are short-lived or designed for batch scripts, so
there's no need to cache the importer result internally.

4 years agoxapcmd: localize %SIG changes using "local"
Eric Wong [Wed, 13 Nov 2019 07:57:38 +0000 (07:57 +0000)]
xapcmd: localize %SIG changes using "local"

Perl's "local" allows changes to %SIG (and %ENV) to be limited
to its enclosing block.  This allows us to get rid of a global
variable and ad-hoc method for restoring signal handlers.

4 years agosolvergit: use --unidiff-zero with git-apply(1)
Eric Wong [Thu, 14 Nov 2019 01:03:38 +0000 (01:03 +0000)]
solvergit: use --unidiff-zero with git-apply(1)

I sometimes post context-free documentation patches generated
with "-U0" to reduce size and bandwidth overhead when replacing
URLs or updating copyright notices.  git-apply(1) needs the
--unidiff-zero switch to work properly with context-free
patches.

Given our search looks for blob OIDs, and we're never going
to be running the code we regenerate, "--unidiff-zero" ought
to be safe.

4 years agodoc: drop a repeated word
Kyle Meyer [Sat, 9 Nov 2019 00:38:06 +0000 (19:38 -0500)]
doc: drop a repeated word

4 years agot/*.t: disable nntpd/httpd worker processes in most tests
Eric Wong [Mon, 4 Nov 2019 03:01:37 +0000 (03:01 +0000)]
t/*.t: disable nntpd/httpd worker processes in most tests

And explicitly test for respawning in t/httpd-corner.t

There's no need to have an extra entries in the process table
for most tests we run, since that's not what we're testing.

4 years agot/hl_mod.t: remove IPC::Run (and File::Temp) dependency
Eric Wong [Mon, 4 Nov 2019 03:01:36 +0000 (03:01 +0000)]
t/hl_mod.t: remove IPC::Run (and File::Temp) dependency

We already load PublicInbox::Spawn for which(), so using spawn()
isn't unreasonable.  And rely on "skip" to log the omitted test
if w3m is missing, which means we need to update the "&&"
escaping test to be self-referential on the same line.

File::Temp was totally unused, there; and we can use "open ...,undef"
in Perl to easily create anonymous temporary files for use with
spawn().

4 years agot/httpd-corner.t: get rid of IPC::Run for running curl
Eric Wong [Mon, 4 Nov 2019 03:01:35 +0000 (03:01 +0000)]
t/httpd-corner.t: get rid of IPC::Run for running curl

We already load PublicInbox::Spawn, so there's no need to
add another dependency to make life difficult for potential
contributors.

4 years agot/httpd-corner.t: drop unnecessary bytes:: for length()
Eric Wong [Mon, 4 Nov 2019 03:01:34 +0000 (03:01 +0000)]
t/httpd-corner.t: drop unnecessary bytes:: for length()

We don't need to force byte semantics for a buffer we clearly
create (via ->read) with byte semantics.  Since we didn't
"use bytes" in t/httpd-corner.t, it was inadvertantly made
available by IPC::Run (which goes away, next).

4 years agot/*.t: remove IPC::Run dependency for git commands
Eric Wong [Mon, 4 Nov 2019 03:01:33 +0000 (03:01 +0000)]
t/*.t: remove IPC::Run dependency for git commands

One small step towards making tests easier-to-run.  We can rely
on "local $ENV{GIT_DIR}" for potentially shell-unsafe path
names, and the rest of our path names are relative and don't
contain characters which require escaping.

4 years agoedit: check for write errors writing "From_" line
Eric Wong [Fri, 8 Nov 2019 20:20:18 +0000 (20:20 +0000)]
edit: check for write errors writing "From_" line

We need to check every print to a regular file for errors,
because storage devices inevitably fail.

4 years agoedit: propagate correct editor exit code
Eric Wong [Fri, 8 Nov 2019 20:20:17 +0000 (20:20 +0000)]
edit: propagate correct editor exit code

exit($?) is never correct, since ($? >> 8) is needed to extract
the correct exit code, as other information (e.g. such as signal)
is encoded in $? in addition to the exit code.

4 years agodoc: actually document publicinboxwatch.watchspam
Eric Wong [Fri, 8 Nov 2019 06:09:02 +0000 (06:09 +0000)]
doc: actually document publicinboxwatch.watchspam

Instead of copy-pasting the documentation for `spamcheck'.

4 years agot/edit: use PublicInbox::Git::qx for pathname safety
Eric Wong [Mon, 4 Nov 2019 11:28:29 +0000 (11:28 +0000)]
t/edit: use PublicInbox::Git::qx for pathname safety

Another case where spaces can be in TMPDIR and cause
shell expansion with `command` to fail.

4 years agotests: rely on PublicInbox::Git for pathname safety
Eric Wong [Mon, 4 Nov 2019 11:13:47 +0000 (11:13 +0000)]
tests: rely on PublicInbox::Git for pathname safety

It's possible (but unlikely) a user will put spaces in TMPDIR
and cause File::Temp::tempdir() to return a temporary directory
with spaces in the filename, making it unsafe for shell
expansion.

PublicInbox::Git didn't exist when t/mda.t was written, and
I just forgot about PublicInbox::Git->qx for t/plack.t :x

4 years agot/httpd-corner.t: check for curl(1) errors in big async test
Eric Wong [Mon, 4 Nov 2019 02:27:23 +0000 (02:27 +0000)]
t/httpd-corner.t: check for curl(1) errors in big async test

curl(1) can fail and we need to invalidate the test in the
rare case it fails.

4 years agoindex: "git log" failures are fatal
Eric Wong [Mon, 4 Nov 2019 00:43:14 +0000 (00:43 +0000)]
index: "git log" failures are fatal

While I've never seen "git log" fail on its own, it could happen
one day and we should be prepared to abort indexing when it
happens.

Beef up tests for t/spawn.t to ensure close() behaves
on popen_rd the way we expect it to.

4 years agosearchidxshard: reuse $SIG{__WARN__} callback from Admin
Eric Wong [Sun, 3 Nov 2019 06:48:58 +0000 (06:48 +0000)]
searchidxshard: reuse $SIG{__WARN__} callback from Admin

We don't want to define $SIG{__WARN__} in the worker to call an
existing non-default callback.  Instead update ->{current_info}
the same way the V2Writable master process does.

I noticed this while reindexing with a large XAPIAN_FLUSH_THRESHOLD
and seeing the wrong epoch on my terminal from a shard because the
shard worker was spawned while reindexing a higher-numbered epoch.

4 years agopublic-inbox v1.2.0 v1.2.0
Eric Wong [Sun, 3 Nov 2019 03:01:40 +0000 (03:01 +0000)]
public-inbox v1.2.0

4 years agobuild: add "git-dist" target for making gzipped tarballs
Eric Wong [Sun, 3 Nov 2019 02:53:39 +0000 (02:53 +0000)]
build: add "git-dist" target for making gzipped tarballs

Since MANIFEST is tied to files tracked by git, adding generated
files such as NEWS to that is more effort than its worth (esp.
when I'm wondering if MakeMaker is useful compared to only using
GNU make).

I also have trouble reading CamelCase, so lower-case names
are nicer and more consistent with previous releases
(which were all generated with "git archive"); but did not
include NEWS.

4 years agodoc: mknews: force plain-text NEWS to UTF-8
Eric Wong [Sun, 3 Nov 2019 02:02:04 +0000 (02:02 +0000)]
doc: mknews: force plain-text NEWS to UTF-8

We'll have non-7-bit ASCII in the 1.2.0 release notes.

4 years agoTODO: update item for multiple Date: headers
Eric Wong [Sun, 3 Nov 2019 01:42:03 +0000 (01:42 +0000)]
TODO: update item for multiple Date: headers

That's the only head-scratcher of the bunch remaining, since
that relies on ranges.

5 years agodoc: add public-inbox.cgi(1) manpage
Eric Wong [Sat, 2 Nov 2019 21:51:08 +0000 (21:51 +0000)]
doc: add public-inbox.cgi(1) manpage

Yet another case of documenting things which should NOT be used :>

5 years agodoc: add public-inbox-purge(1) manpage
Eric Wong [Sat, 2 Nov 2019 21:34:59 +0000 (21:34 +0000)]
doc: add public-inbox-purge(1) manpage

Tools intended for end users need manpages, and doubly so
to convince potential users NOT to use them :)

5 years agohval: replace "&apos;" with "&#39;" for compatibility
Eric Wong [Thu, 31 Oct 2019 09:19:38 +0000 (09:19 +0000)]
hval: replace "&apos;" with "&#39;" for compatibility

While testing 216light.css changes, I managed to hit some cases
where dillo failed to render &apos; correctly, but I also can't
reproduce it reliably.  Anyways, it's definitely a problem with
some old browsers and newer versions of highlight already work
around it, but Debian 10.x has 3.41, so use "&#39;" to maximize
compatibility.

5 years agocontrib/css/216light: improve contrast a bit
Eric Wong [Thu, 31 Oct 2019 09:19:37 +0000 (09:19 +0000)]
contrib/css/216light: improve contrast a bit

"#ff0" foreground on a "#fff" background is just too difficult
to distinguish, among other things.  So choose slightly darker
colors when using a (painful) "#fff" background.

5 years agoqspawn: psgi_qx: delay callback until waitpid returns
Eric Wong [Thu, 31 Oct 2019 05:36:31 +0000 (05:36 +0000)]
qspawn: psgi_qx: delay callback until waitpid returns

We need to detect "git apply" failures reliably when patches
fail.  This is necessary for solving for blob 81c1164ae5 in
https://public-inbox.org/git/ when at least two messages can
solve for it (and one of them fails):

1. https://public-inbox.org/git/b9fb52b8-8168-6bf0-9a72-1e6c44a281a5@oracle.com/
2. https://public-inbox.org/git/56664222-6c29-09dc-ef78-7b380b113c4a@oracle.com/

5 years agosolvergit: deal with false-positive dfpost: results
Eric Wong [Thu, 31 Oct 2019 03:12:20 +0000 (03:12 +0000)]
solvergit: deal with false-positive dfpost: results

When solving for blob 81c1164ae5 in https://public-inbox.org/git/,
at least two messages get indexed with the dfpost result for
that blob (after fixing MsgIter to decode all text/* parts):

1. https://public-inbox.org/git/b9fb52b8-8168-6bf0-9a72-1e6c44a281a5@oracle.com/
2. https://public-inbox.org/git/56664222-6c29-09dc-ef78-7b380b113c4a@oracle.com/

However, only the first message contains a usable patch.  So
we must adjust SolverGit to account for multiple messages
hitting the same "dfpost:" search result and attempt
"git apply" on all results, not just the first.

In the future, changes to SearchIdx.pm may rid us of invalid
search results and speed up performance (at the expense of
developer/indexing time); but we need to account for old search
indices, first.

5 years agomsgiter: attempt to decode all text/* bodies
Eric Wong [Thu, 31 Oct 2019 03:12:19 +0000 (03:12 +0000)]
msgiter: attempt to decode all text/* bodies

We want to index text/x-patch and text/x-diff, at least,
since "git format-patch" can generate a patch series as
attachments using --attach.

5 years agomsgiter: do not assume UTF-8 if Email::MIME->body_str succeeds
Eric Wong [Thu, 31 Oct 2019 00:33:04 +0000 (00:33 +0000)]
msgiter: do not assume UTF-8 if Email::MIME->body_str succeeds

ISO-2202-JP and other non-UTF-8 messages need to be displayed
correctly.

Fixes: 7d82a8bc04ce ('handle "multipart/mixed" messages which are not multipart')
5 years agosearch: add note about SCHEMA_VERSION 15
Eric Wong [Wed, 30 Oct 2019 21:19:46 +0000 (21:19 +0000)]
search: add note about SCHEMA_VERSION 15

--reindex has gotten better over the years, and having parallel
Xapian DB directories would exceed all available disk space for
some users with giant inboxes.