mirror of https://github.com/BOINC/boinc.git
parent
842aadcf0f
commit
1b94875dd7
|
@ -22,18 +22,26 @@ function read_count_file() {
|
|||
}
|
||||
$lines = file("nresults");
|
||||
if (!$lines) return false;
|
||||
return $lines[0];
|
||||
return $lines;
|
||||
}
|
||||
|
||||
function write_count_file($n) {
|
||||
function write_count_file($n,$m) {
|
||||
$f = fopen("nresults", "w");
|
||||
if (!$f) return false;
|
||||
$x = sprintf("%d", $n);
|
||||
$x = sprintf("%d\n%d", $n, $m);
|
||||
fwrite($f, $x);
|
||||
fclose($f);
|
||||
return true;
|
||||
}
|
||||
|
||||
function get_working_count_from_db() {
|
||||
$result = mysql_query("select count(*) from result where server_state = 4");
|
||||
if (!$result) return false;
|
||||
$count = mysql_fetch_array($result);
|
||||
mysql_free_result($result);
|
||||
return $count[0];
|
||||
}
|
||||
|
||||
function get_count_from_db() {
|
||||
$result = mysql_query("select count(*) from result");
|
||||
if (!$result) return false;
|
||||
|
@ -50,15 +58,18 @@ function get_count_from_db() {
|
|||
if ($m == false) {
|
||||
fail("Can't get result count from DB\n");
|
||||
}
|
||||
$p = get_working_count_from_db();
|
||||
if ($p == false) {
|
||||
fail("Can't get working result count from DB\n");
|
||||
}
|
||||
$n = read_count_file();
|
||||
if ($n == false) {
|
||||
write_count_file($m);
|
||||
write_count_file($m,$p);
|
||||
exit();
|
||||
}
|
||||
if ($n == $m) {
|
||||
//echo "fail\n";
|
||||
if (trim($n[0]) == $m && trim($n[1]) == $p) {
|
||||
fail("Result count hasn't changed\n");
|
||||
}
|
||||
write_count_file($m);
|
||||
write_count_file($m,$p);
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue