summaryrefslogtreecommitdiffstats
path: root/modules-available/dnbd3/baseconfig/getconfig.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/dnbd3/baseconfig/getconfig.inc.php')
-rw-r--r--modules-available/dnbd3/baseconfig/getconfig.inc.php13
1 files changed, 8 insertions, 5 deletions
diff --git a/modules-available/dnbd3/baseconfig/getconfig.inc.php b/modules-available/dnbd3/baseconfig/getconfig.inc.php
index e4f84d81..eff821fc 100644
--- a/modules-available/dnbd3/baseconfig/getconfig.inc.php
+++ b/modules-available/dnbd3/baseconfig/getconfig.inc.php
@@ -1,5 +1,8 @@
<?php
+/** @var ?string $uuid */
+/** @var ?string $ip */
+
if (Dnbd3::isEnabled()) {
if (!Dnbd3::hasNfsFallback()) {
ConfigHolder::add("SLX_VM_NFS", false, 1000);
@@ -12,7 +15,7 @@ if (Dnbd3::isEnabled()) {
// Locations from closest to furthest (order)
$locations = ConfigHolder::get('SLX_LOCATIONS');
-if ($locations === false) {
+if ($locations === null) {
$locationIds = [0];
} else {
$locationIds = explode(' ', $locations);
@@ -29,14 +32,14 @@ $res = Database::simpleQuery('SELECT s.fixedip, m.clientip, sxl.locationid FROM
$locationsAssoc = array_flip($locationIds);
$servers = array();
$fallback = array();
-while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+foreach ($res as $row) {
if ($row['fixedip'] === '<self>') {
$row['fixedip'] = Property::getServerIp();
- $defPrio = 2000;
+ $defPrio = Dnbd3::preferLocal() ? 500 : 2000;
} else {
$defPrio = 1000;
}
- $ip = $row['fixedip'] ? $row['fixedip'] : $row['clientip'];
+ $ip = $row['fixedip'] ?: $row['clientip'];
// See if this server is meant for the client at all
if (!is_null($row['locationid']) && !isset($locationsAssoc[$row['locationid']])) {
$fallback[$ip] = true;
@@ -50,7 +53,7 @@ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
$row['locationid'] = $serverLoc;
}
}
- $old = isset($servers[$ip]) ? $servers[$ip] : PHP_INT_MAX;
+ $old = $servers[$ip] ?? PHP_INT_MAX;
if (is_null($row['locationid']) || !isset($locationsAssoc[$row['locationid']])) {
$servers[$ip] = min($defPrio . '.' . mt_rand(), $old);
} else {