user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 1/5] spawn: make @RLIMITS an array
  @ 2020-07-01 21:06  7% ` Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2020-07-01 21:06 UTC (permalink / raw)
  To: meta

Making the RLIMITS list a function doesn't allow constant
folding, so just make it an array accessible to other modules.
---
 lib/PublicInbox/Qspawn.pm | 4 ++--
 lib/PublicInbox/Spawn.pm  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm
index c09e8d2c227..d395a10b3b1 100644
--- a/lib/PublicInbox/Qspawn.pm
+++ b/lib/PublicInbox/Qspawn.pm
@@ -48,7 +48,7 @@ sub _do_spawn {
 	my ($cmd, $cmd_env, $opt) = @{delete $self->{args}};
 	my %o = %{$opt || {}};
 	$self->{limiter} = $limiter;
-	foreach my $k (PublicInbox::Spawn::RLIMITS()) {
+	foreach my $k (@PublicInbox::Spawn::RLIMITS) {
 		if (defined(my $rlimit = $limiter->{$k})) {
 			$o{$k} = $rlimit;
 		}
@@ -358,7 +358,7 @@ sub new {
 
 sub setup_rlimit {
 	my ($self, $name, $config) = @_;
-	foreach my $rlim (PublicInbox::Spawn::RLIMITS()) {
+	foreach my $rlim (@PublicInbox::Spawn::RLIMITS) {
 		my $k = lc($rlim);
 		$k =~ tr/_//d;
 		$k = "publicinboxlimiter.$name.$k";
diff --git a/lib/PublicInbox/Spawn.pm b/lib/PublicInbox/Spawn.pm
index f90d8f6d3dd..ba6e73675fe 100644
--- a/lib/PublicInbox/Spawn.pm
+++ b/lib/PublicInbox/Spawn.pm
@@ -18,7 +18,7 @@ use base qw(Exporter);
 use Symbol qw(gensym);
 use PublicInbox::ProcessPipe;
 our @EXPORT_OK = qw/which spawn popen_rd/;
-sub RLIMITS () { qw(RLIMIT_CPU RLIMIT_CORE RLIMIT_DATA) }
+our @RLIMITS = qw(RLIMIT_CPU RLIMIT_CORE RLIMIT_DATA);
 
 my $vfork_spawn = <<'VFORK_SPAWN';
 #include <sys/types.h>
@@ -209,7 +209,7 @@ sub spawn ($;$$) {
 	}
 	my $rlim = [];
 
-	foreach my $l (RLIMITS()) {
+	foreach my $l (@RLIMITS) {
 		defined(my $v = $opts->{$l}) or next;
 		my $r = eval "require BSD::Resource; BSD::Resource::$l();";
 		unless (defined $r) {

^ permalink raw reply related	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-07-01 21:06     [PATCH 0/5] some random minor fixes Eric Wong
2020-07-01 21:06  7% ` [PATCH 1/5] spawn: make @RLIMITS an array Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).