about summary refs log tree commit homepage
DateCommit message (Collapse)
2019-12-27www: lazy load Plack::Util
cgit users won't need Plack::Util, here.
2019-12-27githttpbackend: split out wwwstatic
Make it easier to share code between our GitHTTPBackend and Cgit packages, for now, and possibly other packages in the future. We can avoid inline_object and anonymous subs at the same time, reducing per-request memory overhead.
2019-12-26qspawn: psgi_return: allow non-anon parse_hdr callback
Callers can supply an arg to parse_hdr, now, eliminating the need for closures to capture local variables.
2019-12-26qspawn: drop "qspawn.filter" support, for now
This feature was added in preparation for future changes that have yet to materialize after nearly 3 years. We can re-add it if needed in the future.
2019-12-26qspawn: psgi_qx: eliminate anonymous subs
We can follow what we did in psgi_return to make psgi_qx allocate less memory on each call.
2019-12-26qspawn: psgi_return_start: hoist out from psgi_return
Instead of just passing the rpipe to the start_cb, pass the entire qspawn ref to start_cb. Update existing callers to avoid circular refs.
2019-12-26qspawn: psgi_return: initial cb can be named
We can take advantage of HTTPD::Async being able to pass user-supplied args to callbacks to get rid of one (of many) anonymous subs in the code path.
2019-12-26httpd/async: get rid of ephemeral main_cb
Cheaper to use up two hash table slots than creating a new sub.
2019-12-26qspawn: reduce local vars, de-anonymize rd_hdr
rd_hdr() now becomes a named subroutine instead of a per-call local variable, so kilobytes of memory will not have to be allocated for it on every ->psgi_return call.
2019-12-26msg_iter: provide means to stop using anonymous subs
And remove the last anonymous sub in SolverGit itself.
2019-12-26qspawn: replace anonymous $end callbacks w/ event_step
This will tie into the DS event loop if that's used, but event_step an be called directly without relying on the event loop from Apache or other HTTP servers (or PSGI tests).
2019-12-26qspawn: disambiguate command vs PSGI env
Make things easier-to-follow and paves the way for future work to reduce dependencies on anonymous subs capturing local variables.
2019-12-26qspawn: remove some anonymous subs for psgi_qx
By passing a user-supplied arg to $qx_cb, we can eliminate the callers' need to capture on-stack variables with a closure. This saves several kilobytes of memory allocation at the expense of some extra hash table lookups in user-supplied callbacks. It also reduces the risk of memory leaks by eliminating a common source of circular references.
2019-12-26httpd/async: support passing arg to callbacks
Another step towards removing anonymous subs to eliminate a possible source of memory leaks and high memory use.
2019-12-26git: allow async_cat to pass arg to callback
This allows callers to avoid allocating several KB for for every call to ->async_cat.
2019-12-26wwwlisting: do not rely on $? after ProcessPipe::CLOSE
ProcessPipe::CLOSE won't reliably set $? inside the event loop if waitpid(..., WNOHANG) isn't successful. So use a blocking waitpid() call, here, and hope "git show-ref" exits promptly since we've already drained its stdout.
2019-12-26t/solver_git: test with -httpd, too
Solver uses the internal -httpd async API if available for fairness when applying large patchsets. We must test those code paths in addition to the generic PSGI code paths.
2019-12-26t/www_listing: test "all" HTML listing
We now have coverage for PublicInbox::WwwListing::list_all.
2019-12-26t/www_listing: quiet down stderr in -httpd
We need to init all.git for the v2 repo test to ensure `git --git-dir=v2/all.git rev-parse --git-path objects/info/alternates` doesn't warn or fail and clutter stderr. This is noticeable when setting TAIL="tail -F" in env before running this test.
2019-12-25t/psgi_v2: test search results Atom feed endpoint
The "x=A" search results endpoint finally gets test coverage.
2019-12-24t/search.t: update permissions check for OpenBSD
OpenBSD (tested 6.5 on amd64) seems to follow the same semantics as FreeBSD for S_ISGID, even if config.mak.uname in git.git doesn't say so.
2019-12-24search: support SWIG-generated Xapian.pm
Xapian upstream is slowly phasing out the XS-based Search::Xapian in favor of the SWIG-generated "Xapian" package. While Debian and both FreeBSD have Search::Xapian, OpenBSD only includes the "Xapian" binding. More information about the status of the "Xapian" Perl module here: https://trac.xapian.org/ticket/523
2019-12-24searchidx: call "++" on PostingIterator instead of "->inc"
The "++" is not yet available in the SWIG-based "Xapian.pm" Perl bindings, so use "++" where it's supported in both the XS (Search::Xapian) and SWIG-based Xapian binding.
2019-12-24testcommon: add require_mods method and use it
This cuts down on lines of code in individual test cases and fixes some misnamed error messages by using "$0" consistently. This will also provide us with a method of swapping out dependencies which provide equivalent functionality (e.g "Xapian" SWIG can replace "Search::Xapian" XS bindings).
2019-12-24remove "no warnings 'once'" in a few places
We can use "use" to get the namespace into the "BEGIN" phase of the interpreter. While we're at it, use \&coderef syntax explicitly instead of globbing everything.
2019-12-22nntp: cmd_xover: use named sub for long_response
Introduce xover_i, which does the same thing as the anonymous sub it replaces.
2019-12-22nntp: hdr_msg_id: use named sub for long_response
Introduce hdr_msgid_range_i, which does the same thing as the anonymous sub it replaces.
2019-12-22nntp: cmd_newnews: use named sub for long_response
Introduce newnews_i, which does the same thing as the anonymous sub it replaces.
2019-12-22nntp: cmd_listgroup: use named subs for long_response
Introduce listgroup_range_i and listgroup_all_i subs which do the same things as the anonymous subs they replace.
2019-12-22nntp: cmd_xrover: use named sub for long_response
Introduce xrover_i which does the same thing as the anonymous sub it replaces.
2019-12-22nntp: hdr_searchmsg: use named sub for numeric range response
Introduce searchmsg_range_i, which does the same thing as the anonymous sub it replaces.
2019-12-22nntp: remove cyclic refs from long_response
Leftover cyclic references are a source of memory leaks. While our code is AFAIK unaffected by such leaks at the moment, eliminating a potential source of bugs will make maintenance easier. We make the long_response API cycle-free by stashing the callback into the NNTP object. However, callers will need to be updated to get rid of the circular reference to $self. We do that be replacing anonymous subs with name subroutine references, such as xref_range_i replacing the formerly anonymous sub inside hdr_xref.
2019-12-22nntp: get_range: return scalarref for $beg
...Instead of just returning a plain scalar inside an arrayref. This is because we usually pass the result of NNTP::get_range to Msgmap::msg_range. Upcoming changes will move us away from anonymous subroutines, so this change will make followup commits easier-to-digest as modifications to the underlying scalar can be more easily propagated between non-anonymous-subs.
2019-12-22http: avoid anonymous sub for getline callback
We can avoid the danger of self-referential subs entirely for code internal to PublicInbox::HTTP. This change was only made possible by commit 8e1c3155da4edc082e8e3d8b30351f0c861757a7 ("ds: pass $self to code references")
2019-12-22http: get rid of anonymous subs for write/close
Each sub costs us several kilobytes of memory for every response we make. An arrayref only costs 80 bytes on 64-bit, so bless that to packages with appropriate ->write and ->close methods.
2019-12-22nntp: get rid of some unused imports
Our NNTP code no longer relies on search or Xapian. Msgmap and Git modules are loaded anyways through Inbox->(git|mm|over) methods, however.
2019-12-22nntp: simplify method detection using UNIVERSAL::can
No need to do an eval dance or disable strict refs.
2019-12-22testcommon: require_git: use "plan" from Test::More
require_git is no longer in the "::main" namespace, so we must call Test::More::plan() explicitly.
2019-12-21searchview: save a column in &x=t thread skeleton
Displaying "100%" wastes a precious column. Show "99%" instead since there's little practical difference and <xapian/mset.h> states: Note that these generally aren't percentages of anything meaningful (unless you use a custom weighting formula where they are!) And we're not using a custom weighting formula.
2019-12-20view: show percentage in search results thread skeleton
The displays the Xapian ->get_percent value in the skeleton to improve scanning of relevancy; irrelevant results do not display that. This fixes broken #anchor links introduced in the previous commit, irrelevant messages now link to the /$INBOX/$MESSAGE_ID page.
2019-12-20searchthread: fix usage of user-supplied parameter
Instead of only passing an Inbox object, we'll pass the $ctx reference as PublicInbox::SearchView::mset_thread did. So although mset_thread was wrong, we now make it's usage of SearchThread::thread correct and update other callers to favor the new style of passing the entire $ctx (with ->{-inbox}) instead of just the Inbox object. This makes the thread skeleton at the bottom of the search page to show subjects of messages, but unfortunately links to non-existent #anchors. The next commit will fix that. While we're at it, favor "\&foo" over "*foo" since the former makes the code reference (aka "function pointer) obvious so it won't be confused for other things named "foo" in that scope (e.g. $foo/@foo/%foo).
2019-12-20testcommon: fix run_script for older Perls
Using Perl "open" to dup(2) and save the old handles is required since "local *STDIN = *STDIN" does not work on old Perls. Even worse, this was silently a no-op when tested with Perl 5.24.1 on Debian 9.x and led to confusing failures in the t/httpd-corner.t lsof(1) tests when run after t/v2mirror.t from the same worker process using t/run.perl.
2019-12-19t/run.perl: to avoid repeated process spawning for *.t
Spawning a new Perl interpreter for every test case means Perl has to reparse and recompile every single file it needs, costing us performance and development time. Now that we've modified our code to avoid global state, we can preload everything we need. The new "check-run" test target is now 20-30% faster than the original "check" target.
2019-12-19tests: move t/common.perl to PublicInbox::TestCommon
We want to be able to use run_script with *.t files, so t/common.perl putting subs into the top-level "main" namespace won't work. Instead, make it a module which uses Exporter like other libraries.
2019-12-19t/*.t: avoid sharing "my" variables in subs
These usages of file-local global variables make the *.t files incompatible with run_script(). Instead, use anonymous subs, "our", or pass the parameter as appropriate.
2019-12-19msgiter: msg_part_text returns undef on text/html
We want HTML parts to be downloadable, but not displayed as unreadable (but injection-safe) HTML source in our own web and Atom interfaces. This affects indexing, too, as HTML tags/comments won't be indexed anymore, but existing indices are only cleaned after --reindex. HTML-only mail won't be indexed at all, but we won't cross that bridge until somebody cares about that crap. We'll continue to actively discourage such waste of CPU cycles, bandwidth, cache and storage. Fixes: 7d82a8bc04ce2e68 (handle "multipart/mixed" messages which are not multipart')
2019-12-18Makefile.PL: sort target and var lists
Sorting makes it easier to review the generated result.
2019-12-18viewvcs: flesh out some functionality and test
Expose MAX_SIZE via "our" will make it possible to use in tests, and configure, later. Additionally, returning HTTP 500 code for big files is not an Internal Server Error, just a memory limit... Some browsers won't show our HTML response with the link to the raw file in case of errors, either, so we'll return 200 to ensure users can use the link to access the raw blob. Finally, throw in some tests to the existing solver_git testcase, since that was incomplete and was pointlessly loading Plack modules without testing PSGI.
2019-12-18TODO: add UUCP address item
We should support historical archives from the old days, but I'm not sure how to best go about it, for now, given how tricky correct handling of modern email addresses is. We can deal with it if/when somebody decides to import some ancient archives...
2019-12-17Makefile.PL: allow overriding "prove" from make CLI
Development versions of Perl install "prove$VERSION" where $VERSION is something like "5.31.7". This makes it easier to test everything we have against development versions of Perl5. Note: I could not find a way to get quoting right to use the "--exec $(PERL)" option of prove(1), but that would be the best option for working transparently after running: perl5.31.7 Makefile.PL