Merge pull request #3502 from annando/1705-self-probing
Don't quit if the own host cannot be reached via SSL
This commit is contained in:
commit
62a7c8ed67
|
@ -417,8 +417,6 @@ function poller_too_much_workers() {
|
|||
|
||||
$maxqueues = $queues;
|
||||
|
||||
$active = poller_active_workers();
|
||||
|
||||
// Decrease the number of workers at higher load
|
||||
$load = current_load();
|
||||
if ($load) {
|
||||
|
@ -431,6 +429,33 @@ function poller_too_much_workers() {
|
|||
$slope = $maxworkers / pow($maxsysload, $exponent);
|
||||
$queues = ceil($slope * pow(max(0, $maxsysload - $load), $exponent));
|
||||
|
||||
$active = 0;
|
||||
|
||||
// Create a list of queue entries grouped by their priority
|
||||
$listitem = array();
|
||||
|
||||
// Adding all processes with no workerqueue entry
|
||||
$processes = dba::p("SELECT COUNT(*) AS `running` FROM `process` WHERE NOT EXISTS (SELECT id FROM `workerqueue` WHERE `workerqueue`.`pid` = `process`.`pid`)");
|
||||
if ($process = dba::fetch($processes)) {
|
||||
$listitem[0] = "0:".$process["running"];
|
||||
$active += $process["running"];
|
||||
}
|
||||
dba::close($processes);
|
||||
|
||||
// Now adding all processes with workerqueue entries
|
||||
$entries = dba::p("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` GROUP BY `priority`");
|
||||
while ($entry = dba::fetch($entries)) {
|
||||
$processes = dba::p("SELECT COUNT(*) AS `running` FROM `process` LEFT JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` WHERE `priority` = ?", $entry["priority"]);
|
||||
if ($process = dba::fetch($processes)) {
|
||||
$listitem[$entry["priority"]] = $entry["priority"].":".$process["running"]."/".$entry["entries"];
|
||||
$active += $process["running"];
|
||||
}
|
||||
dba::close($processes);
|
||||
}
|
||||
dba::close($entries);
|
||||
|
||||
$processlist = implode(', ', $listitem);
|
||||
|
||||
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `executed` <= '%s'", dbesc(NULL_DATE));
|
||||
$entries = $s[0]["total"];
|
||||
|
||||
|
@ -448,27 +473,6 @@ function poller_too_much_workers() {
|
|||
}
|
||||
}
|
||||
|
||||
// Create a list of queue entries grouped by their priority
|
||||
$running = array(PRIORITY_CRITICAL => 0,
|
||||
PRIORITY_HIGH => 0,
|
||||
PRIORITY_MEDIUM => 0,
|
||||
PRIORITY_LOW => 0,
|
||||
PRIORITY_NEGLIGIBLE => 0);
|
||||
|
||||
$r = q("SELECT COUNT(*) AS `running`, `priority` FROM `process` INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` GROUP BY `priority`");
|
||||
if (dbm::is_result($r))
|
||||
foreach ($r AS $process)
|
||||
$running[$process["priority"]] = $process["running"];
|
||||
|
||||
$processlist = "";
|
||||
$r = q("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` GROUP BY `priority`");
|
||||
if (dbm::is_result($r))
|
||||
foreach ($r as $entry) {
|
||||
if ($processlist != "")
|
||||
$processlist .= ", ";
|
||||
$processlist .= $entry["priority"].":".$running[$entry["priority"]]."/".$entry["entries"];
|
||||
}
|
||||
|
||||
logger("Load: ".$load."/".$maxsysload." - processes: ".$active."/".$entries." (".$processlist.") - maximum: ".$queues."/".$maxqueues, LOGGER_DEBUG);
|
||||
|
||||
// Are there fewer workers running as possible? Then fork a new one.
|
||||
|
@ -478,6 +482,8 @@ function poller_too_much_workers() {
|
|||
$a = get_app();
|
||||
$a->proc_run($args);
|
||||
}
|
||||
} else {
|
||||
$active = poller_active_workers();
|
||||
}
|
||||
|
||||
return($active >= $queues);
|
||||
|
|
|
@ -58,6 +58,28 @@ class Probe {
|
|||
return $newdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the hostname belongs to the own server
|
||||
*
|
||||
* @param string $host The hostname that is to be checked
|
||||
*
|
||||
* @return bool Does the testes hostname belongs to the own server?
|
||||
*/
|
||||
private function ownHost($host) {
|
||||
$own_host = get_app()->get_hostname();
|
||||
|
||||
$parts = parse_url($host);
|
||||
|
||||
if (!isset($parts['scheme'])) {
|
||||
$parts = parse_url('http://'.$host);
|
||||
}
|
||||
|
||||
if (!isset($parts['host'])) {
|
||||
return false;
|
||||
}
|
||||
return $parts['host'] == $own_host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Probes for XRD data
|
||||
*
|
||||
|
@ -82,7 +104,7 @@ class Probe {
|
|||
logger("Probing for ".$host, LOGGER_DEBUG);
|
||||
|
||||
$ret = z_fetch_url($ssl_url, false, $redirects, array('timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml'));
|
||||
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
|
||||
if (($ret['errno'] == CURLE_OPERATION_TIMEDOUT) AND !self::ownHost($ssl_url)) {
|
||||
logger("Probing timeout for ".$ssl_url, LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue