]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchidx: use Perl truthiness to detect XAPIAN_FLUSH_THRESHOLD
authorEric Wong <e@yhbt.net>
Fri, 7 Aug 2020 10:52:17 +0000 (10:52 +0000)
committerEric Wong <e@yhbt.net>
Fri, 7 Aug 2020 23:46:14 +0000 (23:46 +0000)
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= <command>' 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

index 2248973131d16ba690ce42c68be7082ee8e270c7..01b9f52dff965a0c7f334867c2d9ad9e2fd6e4d6 100644 (file)
@@ -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/;