From 5a33d70f90921618da5c3813db4842e975c1d963 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Thu, 10 Jul 2014 07:23:40 +0300 Subject: [PATCH] Put sanity check into time bias function --- src/stratifier.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/stratifier.c b/src/stratifier.c index 70de9289..e87a2e31 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1276,7 +1276,12 @@ static void stratum_send_message(stratum_instance_t *client, const char *msg) static double time_bias(double tdiff, double period) { - return 1.0 - 1.0 / exp(tdiff / period); + double dexp = tdiff / period; + + /* Sanity check to prevent silly numbers for double accuracy **/ + if (unlikely(dexp > 36)) + dexp = 36; + return 1.0 - 1.0 / exp(dexp); } /* Sanity check to prevent clock adjustments backwards from screwing up stats */