From 3b910336cef56267bdbecd9cad6a80ac44350ae8 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 18 Dec 2012 22:48:56 +1100 Subject: [PATCH] Protect the best_share/best_diff values under control lock. --- cgminer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cgminer.c b/cgminer.c index 335f77ee..329f680a 100644 --- a/cgminer.c +++ b/cgminer.c @@ -2352,10 +2352,12 @@ static uint64_t share_diff(const struct work *work) if (unlikely(!d64)) d64 = 1; ret = diffone / d64; + mutex_lock(&control_lock); if (ret > best_diff) { best_diff = ret; suffix_string(best_diff, best_share, 0); } + mutex_unlock(&control_lock); return ret; } @@ -2367,10 +2369,12 @@ static uint64_t scrypt_diff(const struct work *work) if (unlikely(!d64)) d64 = 1; ret = scrypt_diffone / d64; + mutex_lock(&control_lock); if (ret > best_diff) { best_diff = ret; suffix_string(best_diff, best_share, 0); } + mutex_unlock(&control_lock); return ret; }