From d9e073410dc29e24fc644dc5f1d8da2af97255a0 Mon Sep 17 00:00:00 2001 From: h4waii <30473690+h4waii@users.noreply.github.com> Date: Mon, 24 Feb 2020 00:04:06 +1100 Subject: [PATCH] fix: #520 - free mutex after work is done Why not just free after key found or not found? --- client/cmdhfmfhard.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/client/cmdhfmfhard.c b/client/cmdhfmfhard.c index f9e68ca67..32afd8cf2 100644 --- a/client/cmdhfmfhard.c +++ b/client/cmdhfmfhard.c @@ -1845,14 +1845,15 @@ static bool TestIfKeyExists(uint64_t key) { num_keys_tested += count; hardnested_print_progress(num_acquired_nonces, "(Test: Key found)", 0.0, 0); crypto1_destroy(pcs); + pthread_mutex_destroy(&statelist_cache_mutex); return true; } } num_keys_tested += count; hardnested_print_progress(num_acquired_nonces, "(Test: Key NOT found)", 0.0, 0); - crypto1_destroy(pcs); + pthread_mutex_destroy(&statelist_cache_mutex); return false; } @@ -2042,9 +2043,6 @@ static void generate_candidates(uint8_t sum_a0_idx, uint8_t sum_a8_idx) { pthread_join(thread_id[i], NULL); } - // clean up mutex - pthread_mutex_destroy(&statelist_cache_mutex); - maximum_states = 0; for (statelist_t *sl = candidates; sl != NULL; sl = sl->next) { maximum_states += (uint64_t)sl->len[ODD_STATE] * sl->len[EVEN_STATE];