From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id B301B1FA0F for ; Fri, 7 Aug 2020 10:52:19 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/5] searchidx: use Perl truthiness to detect XAPIAN_FLUSH_THRESHOLD Date: Fri, 7 Aug 2020 10:52:17 +0000 Message-Id: <20200807105218.16843-5-e@yhbt.net> In-Reply-To: <20200807105218.16843-1-e@yhbt.net> References: <20200807105218.16843-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: XAPIAN_FLUSH_THRESHOLD is a C string in the environment, so users may be tempted to assign an empty string in in their shell, e.g. `XAPIAN_FLUSH_THRESHOLD= ' instead of using `unset' POSIX shell built-in. With either a value of "0" or "" (empty string), Xapian will fall back to its default (10000 documents), which causes grief for memory-starved users. --- lib/PublicInbox/SearchIdx.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 22489731..01b9f52d 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -25,8 +25,7 @@ our @EXPORT_OK = qw(crlf_adjust log2stack is_ancestor check_size nodatacow_dir); my $X = \%PublicInbox::Search::X; my ($DB_CREATE_OR_OPEN, $DB_OPEN); our $DB_NO_SYNC = 0; -our $BATCH_BYTES = defined($ENV{XAPIAN_FLUSH_THRESHOLD}) ? - 0x7fffffff : 1_000_000; +our $BATCH_BYTES = $ENV{XAPIAN_FLUSH_THRESHOLD} ? 0x7fffffff : 1_000_000; use constant DEBUG => !!$ENV{DEBUG}; my $xapianlevels = qr/\A(?:full|medium)\z/;