diff options
author | Eric Wong <e@80x24.org> | 2024-01-30 07:22:21 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2024-01-30 08:28:55 +0000 |
commit | 53eafcd90a3179200192263807cf3df7c869b500 (patch) | |
tree | 254a2f9cf1efc98f87b4ac453f69a4356ebac7cb /lib/PublicInbox/Limiter.pm | |
parent | 6b8bcf8bb0afc843e563862ae50a02d41aaba129 (diff) | |
download | public-inbox-53eafcd90a3179200192263807cf3df7c869b500.tar.gz |
BSD::Resource isn't packaged for Alpine (as of 3.19), but we also have optional Inline::C support and already rely on calling setrlimit(2) directly from the Inline::C version of pi_fork_exec.
Diffstat (limited to 'lib/PublicInbox/Limiter.pm')
-rw-r--r-- | lib/PublicInbox/Limiter.pm | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/PublicInbox/Limiter.pm b/lib/PublicInbox/Limiter.pm index 48a2b6a3..a8d08fc3 100644 --- a/lib/PublicInbox/Limiter.pm +++ b/lib/PublicInbox/Limiter.pm @@ -31,14 +31,17 @@ sub setup_rlimit { } elsif (scalar(@rlimit) != 2) { warn "could not parse $k: $v\n"; } - eval { require BSD::Resource }; - if ($@) { - warn "BSD::Resource missing for $rlim"; - next; - } + my $inf = $v =~ /\binfinity\b/i ? + $PublicInbox::Spawn::RLIMITS{RLIM_INFINITY} // eval { + require BSD::Resource; + BSD::Resource::RLIM_INFINITY(); + } // do { + warn "BSD::Resource missing for $rlim"; + next; + } : undef; for my $i (0..$#rlimit) { next if $rlimit[$i] ne 'INFINITY'; - $rlimit[$i] = BSD::Resource::RLIM_INFINITY(); + $rlimit[$i] = $inf; } $self->{$rlim} = \@rlimit; } |