From 050c347f31f25d428c9e019a6ae63ec2c248a847 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 21 Feb 2017 06:44:08 -0800 Subject: [PATCH] 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. --- doc/get_platforms.inc | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/doc/get_platforms.inc b/doc/get_platforms.inc index 444475076e..4f8273076f 100644 --- a/doc/get_platforms.inc +++ b/doc/get_platforms.inc @@ -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;