about summary refs log tree commit homepage
path: root/lib/PublicInbox/Limiter.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/Limiter.pm')
-rw-r--r--lib/PublicInbox/Limiter.pm15
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;
         }