Skip to content

Commit 78e6ebc

Browse files
committed
Addressing few remarks
1 parent 18d2efa commit 78e6ebc

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

sapi/fpm/fpm/fpm_unix.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ static int fpm_cpuaffinity_set(struct fpm_cpuaffinity_conf *c)
451451

452452
static void fpm_cpuaffinity_destroy(struct fpm_cpuaffinity_conf *c)
453453
{
454-
// some platform/apis requires to allocates data on the heap
454+
// some platform/apis require to allocates data on the heap
455455
}
456456

457457
static int fpm_setcpuaffinity(char *cpumask)
@@ -470,8 +470,8 @@ static int fpm_setcpuaffinity(char *cpumask)
470470
char *cpumasksep;
471471

472472
fconf.min = strtol(token, &cpumasksep, 0);
473-
if (errno || fconf.min > cpumax) {
474-
goto fail;
473+
if (errno || fconf.min < 0 || fconf.min > cpumax) {
474+
return -1;
475475
}
476476
fconf.max = fconf.min;
477477
if (*cpumasksep == '-') {
@@ -491,7 +491,6 @@ static int fpm_setcpuaffinity(char *cpumask)
491491
token = php_strtok_r(NULL, ";", &buf);
492492
}
493493

494-
fail:
495494
r = fpm_cpuaffinity_set(&fconf);
496495
fpm_cpuaffinity_destroy(&fconf);
497496
return r;

sapi/fpm/php-fpm.conf.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
;systemd_interval = 10
127127

128128
; Bind the master process to a cpu set.
129-
; The value can be one cpu id or a range.
129+
; The value can be one cpu id, a range or a list thereof.
130130
;
131131
; Default Value: not set
132132
; process.cpumask = "4"

sapi/fpm/tests/cpuaffinity-fail.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ EOT;
2828

2929
$tester = new FPM\Tester($cfg);
3030
$tester->start();
31-
$tester->expectLogError("failed to fpm_setcpuaffinity\(\d+\): Invalid argument \(\d+\)");
31+
$tester->expectLogError("failed to fpm_setcpuaffinity\(\d+\): Inappropriate ioctl for device \(\d+\)");
3232
$tester->expectLogError("FPM initialization failed");
3333
$tester->close();
3434

sapi/fpm/tests/cpuaffinity.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ FPM: cpu affinity test
66
if (!str_contains(PHP_OS, 'Linux')) {
77
die('skipped supported only on Linux');
88
}
9+
$nproc = intval(exec("nproc"));
10+
if ($nproc < 2) {
11+
die('skipped supported only on multicores environments');
12+
}
913
?>
1014
--FILE--
1115
<?php

sapi/fpm/www.conf.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ listen = 127.0.0.1:9000
8181
; process.priority = -19
8282

8383
; Bind the pool processes to a cpu set.
84-
; The value can be one cpu id or a range.
84+
; The value can be one cpu id, a range or a list thereof.
8585
;
8686
; Default Value: inherits master's cpu affinity
8787
; process.cpumask = "8"

0 commit comments

Comments
 (0)