Browse Source

ckdb - avoid divide by zero

master
kanoi 10 years ago
parent
commit
43ca551c24
  1. 13
      pool/page.php
  2. 4
      src/ckdb.c

13
pool/page.php

@ -199,7 +199,18 @@ function pgtop($dotop, $user, $douser)
} }
if (isset($info['blockacc'])) if (isset($info['blockacc']))
$pac = number_format($info['blockacc'], 0); {
$acc = $info['blockacc'];
$pac = number_format($acc, 0);
if ($acc >= 1000000)
$pac .= ' '.siprefmt($acc);
if (isset($info['currndiff']))
{
$cur = $info['currndiff'];
if ($cur != '?' && $cur > 0.0)
$pac .= ' ('.number_format(100.0*$acc/$cur, 2).'%)';
}
}
if (isset($info['blockerr'])) if (isset($info['blockerr']))
$per = number_format($info['blockerr'], 0); $per = number_format($info['blockerr'], 0);

4
src/ckdb.c

@ -4976,15 +4976,15 @@ flail:
else { else {
char pct[16] = "?"; char pct[16] = "?";
char est[16] = ""; char est[16] = "";
if (pool.diffacc) {
K_ITEM *w_item; K_ITEM *w_item;
w_item = find_workinfo(DATA_BLOCKS(b_item)->workinfoid); w_item = find_workinfo(DATA_BLOCKS(b_item)->workinfoid);
if (w_item) { if (w_item) {
char wdiffbin[TXT_SML+1]; char wdiffbin[TXT_SML+1];
double wdiff; double wdiff;
hex2bin(wdiffbin, DATA_WORKINFO(w_item)->bits, 4); hex2bin(wdiffbin, DATA_WORKINFO(w_item)->bits, 4);
wdiff = diff_from_nbits(wdiffbin); wdiff = diff_from_nbits(wdiffbin);
if (wdiff > 0.0) {
snprintf(pct, sizeof(pct), "%.2f", snprintf(pct, sizeof(pct), "%.2f",
100.0 * pool.diffacc / wdiff); 100.0 * pool.diffacc / wdiff);
} }

Loading…
Cancel
Save