Skip to content

Commit e61c205

Browse files
committed
Addressing few remarks
1 parent 7b9ec3b commit e61c205

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
@@ -408,7 +408,7 @@ static int fpm_cpuaffinity_set(struct fpm_cpuaffinity_conf *c)
408408

409409
static void fpm_cpuaffinity_destroy(struct fpm_cpuaffinity_conf *c)
410410
{
411-
// some platform/apis requires to allocates data on the heap
411+
// some platform/apis require to allocates data on the heap
412412
}
413413

414414
static int fpm_setcpuaffinity(char *cpumask)
@@ -427,8 +427,8 @@ static int fpm_setcpuaffinity(char *cpumask)
427427
char *cpumasksep;
428428

429429
fconf.min = strtol(token, &cpumasksep, 0);
430-
if (errno || fconf.min > cpumax) {
431-
goto fail;
430+
if (errno || fconf.min < 0 || fconf.min > cpumax) {
431+
return -1;
432432
}
433433
fconf.max = fconf.min;
434434
if (*cpumasksep == '-') {
@@ -448,7 +448,6 @@ static int fpm_setcpuaffinity(char *cpumask)
448448
token = php_strtok_r(NULL, ";", &buf);
449449
}
450450

451-
fail:
452451
r = fpm_cpuaffinity_set(&fconf);
453452
fpm_cpuaffinity_destroy(&fconf);
454453
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
@@ -75,7 +75,7 @@ listen = 127.0.0.1:9000
7575
; process.priority = -19
7676

7777
; Bind the pool processes to a cpu set.
78-
; The value can be one cpu id or a range.
78+
; The value can be one cpu id, a range or a list thereof.
7979
;
8080
; Default Value: inherits master's cpu affinity
8181
; process.cpumask = "8"

0 commit comments

Comments
 (0)