From 7e8019acddf6325c5227845be1fe57c4af16fe2e Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 15 Feb 2013 16:13:24 +1100 Subject: [PATCH] Do as much outside of mutex locking of sshare_lock as possible. --- cgminer.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cgminer.c b/cgminer.c index bec123f3..23420309 100644 --- a/cgminer.c +++ b/cgminer.c @@ -3156,17 +3156,19 @@ static void *submit_work_thread(void *userdata) sshare->sshare_time = time(NULL); /* This work item is freed in parse_stratum_response */ sshare->work = work; + nonce = *((uint32_t *)(work->data + 76)); + noncehex = bin2hex((const unsigned char *)&nonce, 4); + memset(s, 0, 1024); + h32 = hash32[6]; + mutex_lock(&sshare_lock); /* Give the stratum share a unique id */ sshare->id = swork_id++; HASH_ADD_INT(stratum_shares, id, sshare); - nonce = *((uint32_t *)(work->data + 76)); - noncehex = bin2hex((const unsigned char *)&nonce, 4); - memset(s, 0, 1024); sprintf(s, "{\"params\": [\"%s\", \"%s\", \"%s\", \"%s\", \"%s\"], \"id\": %d, \"method\": \"mining.submit\"}", pool->rpc_user, work->job_id, work->nonce2, work->ntime, noncehex, sshare->id); - h32 = hash32[6]; mutex_unlock(&sshare_lock); + free(noncehex); applog(LOG_INFO, "Submitting share %08lx to pool %d", h32, pool->pool_no);