summaryrefslogtreecommitdiff
path: root/update_daemon2.php
diff options
context:
space:
mode:
authorwn_ <[email protected]>2021-11-11 12:11:30 +0000
committerwn_ <[email protected]>2021-11-11 12:11:33 +0000
commit0f324b77df21631b183c98d67dbb08750be9d2e1 (patch)
tree21b6e01458a783d7d80100ed3da8eb7ec80ecc06 /update_daemon2.php
parent7a919a79d7b504c591ba2360b68f2e401675fdae (diff)
Address PHPStan warning and tweak 'tasks'+'interval' handling in 'update_daemon2.php'.
This ensures both are of the expected type (int) and meet a reasonable minimum.
Diffstat (limited to 'update_daemon2.php')
-rwxr-xr-xupdate_daemon2.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/update_daemon2.php b/update_daemon2.php
index 06a31225e..eea790c8b 100755
--- a/update_daemon2.php
+++ b/update_daemon2.php
@@ -130,7 +130,7 @@
$options = getopt("", $longopts);
- if (isset($options["help"]) ) {
+ if ($options === false || isset($options["help"]) ) {
print "Tiny Tiny RSS update daemon.\n\n";
print "Options:\n";
print " --log FILE - log messages to FILE\n";
@@ -161,21 +161,28 @@
if (isset($options["tasks"])) {
Debug::log("Set to spawn " . $options["tasks"] . " children.");
- $max_jobs = $options["tasks"];
+ $max_jobs = (int) $options["tasks"];
} else {
$max_jobs = Config::get(Config::DAEMON_MAX_JOBS);
}
+ if ($max_jobs < 1) {
+ $max_jobs = 1;
+ Debug::log("Enforced minimum task count of $max_jobs.");
+ }
+
if (isset($options["interval"])) {
Debug::log("Spawn interval: " . $options["interval"] . " seconds.");
- $spawn_interval = $options["interval"];
+ $spawn_interval = (int) $options["interval"];
} else {
$spawn_interval = Config::get(Config::DAEMON_SLEEP_INTERVAL);
}
// let's enforce a minimum spawn interval as to not forkbomb the host
- $spawn_interval = max(60, $spawn_interval);
- Debug::log("Spawn interval: $spawn_interval sec");
+ if ($spawn_interval < 60) {
+ $spawn_interval = 60;
+ Debug::log("Enforced minimum task spawn interval of $spawn_interval seconds.");
+ }
if (file_is_locked("update_daemon.lock")) {
die("error: Can't create lockfile. ".