Skip to content

Commit

Permalink
Fix bogus suffix warnings in autotune.php (#691)
Browse files Browse the repository at this point in the history
If the is_numeric case statement evaluates to true, and the suffix is a 0 (e.g. because the input value is "2684354560" a.k.a. 2.5 GiB), it matches, and prints the warning.

This is not how case statements work (they simply weak-comparison match the switch value against the case expression). The check was supposed to be in the default block all along.
  • Loading branch information
dzuelke committed Feb 9, 2024
1 parent abf8af3 commit 0166860
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## [Unreleased]

### FIX

- `WEB_CONCURRENCY` auto-tuning may warn about an invalid suffix for certain available memory values [David Zuelke]

## [v245] - 2024-02-09

Expand Down
5 changes: 3 additions & 2 deletions bin/util/autotune.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ function stringtobytes($amount) {
case 'k':
$amount = (int)$amount * 1024;
break;
case !is_numeric($suffix):
fprintf(STDERR, "WARNING: ignoring invalid suffix '%s' in 'memory_limit' value '%s'\n", $suffix, $amount);
default:
if(!is_numeric($suffix)) {
fprintf(STDERR, "WARNING: ignoring invalid suffix '%s' in 'memory_limit' value '%s'\n", $suffix, $amount);
}
$amount = (int)$amount;
}
return $amount;
Expand Down

0 comments on commit 0166860

Please sign in to comment.