From e9d5244d44c73316847706982200f5780b283a23 Mon Sep 17 00:00:00 2001 From: Kano Date: Fri, 27 Apr 2012 02:36:04 +1000 Subject: [PATCH] miner.php add a timeout so you don't sit and wait ... forever --- miner.php | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/miner.php b/miner.php index 5d8c55f0..e3a816d5 100644 --- a/miner.php +++ b/miner.php @@ -1,7 +1,7 @@ $socktimeoutsec, 'usec' => 0)); + $res = socket_connect($socket, $addr, $port); if ($res === false) { @@ -569,13 +587,18 @@ function doforeach($cmd, $des, $sum, $head, $datetime) global $miner, $port; global $error, $readonly, $notify, $rigs; global $tablebegin, $tableend, $warnfont, $warnoff, $dfmt; + global $rigerror; $header = $head; $anss = array(); $count = 0; + $preverr = count($rigerror); foreach ($rigs as $rig) { + if (isset($rigerror[$rig])) + continue; + $parts = explode(':', $rig, 2); if (count($parts) == 2) { @@ -588,6 +611,7 @@ function doforeach($cmd, $des, $sum, $head, $datetime) { echo "Error on rig $count getting $des: "; echo $warnfont.$error.$warnoff.''; + $rigerror[$rig] = $error; $error = null; } else @@ -598,7 +622,10 @@ function doforeach($cmd, $des, $sum, $head, $datetime) if (count($anss) == 0) { - echo "Failed to access any rigs successfully"; + echo 'Failed to access any rigs successfully'; + if ($preverr > 0) + echo ' (or rigs had previous errors)'; + echo ''; return; }