Browse Source

Do as much outside of mutex locking of sshare_lock as possible.

Con Kolivas 13 years ago
parent
commit
7e8019acdd
1 changed files with 6 additions and 4 deletions
  1. 6 4
      cgminer.c

+ 6 - 4
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);