BOINC web: fix bug in get_platforms()

There was a logic error that would cause every load of
the project page to initiate a web request to GPUgrid.
When GPUgrid was down, this could create lots of sockets,
which eventually would prevent incoming connections.
I think this is the reason for the sporadic slowdowns
of the BOINC web site.
This commit is contained in:
David Anderson 2017-02-21 06:44:08 -08:00
parent 3f0f36ac5a
commit 050c347f31
1 changed files with 13 additions and 14 deletions

View File

@ -281,22 +281,21 @@ function get_platforms_cached($url) {
$u = urlencode($url);
$fname = "/home/boincadm/boinc/doc/platforms/$u";
$t = @filemtime($fname);
if (!strstr($url, "gpugrid") && $t && $t > time() - 604800) {
$l = json_decode(file_get_contents($fname));
if (strstr($url, "gpugrid") || ($t && $t > time() - 604800)) {
return json_decode(file_get_contents($fname));
}
$l = get_platforms($url);
if (!$l) {
$l = get_platforms2($url);
}
if ($l) {
file_put_contents($fname, json_encode($l));
} else {
$l = get_platforms($url);
if (!$l) {
$l = get_platforms2($url);
}
if ($l) {
file_put_contents($fname, json_encode($l));
if (file_exists($fname)) {
touch($fname);
} else {
if (file_exists($fname)) {
touch($fname);
} else {
$l[] = "Unknown";
file_put_contents($fname, json_encode($l));
}
$l[] = "Unknown";
file_put_contents($fname, json_encode($l));
}
}
return $l;