Browse Source

Set sshare id and swork_id within the sshare mutex to avoid multiple share submits with the same id.

Con Kolivas 13 years ago
parent
commit
e19c5d9db9
1 changed files with 3 additions and 4 deletions
  1. 3 4
      cgminer.c

+ 3 - 4
cgminer.c

@@ -2920,11 +2920,10 @@ static void *submit_work_thread(void *userdata)
 		char *noncehex;
 		char s[1024];
 
-		/* Give the stratum share a unique id */
-		swork_id++;
 		memcpy(&sshare->work, work, sizeof(struct work));
 		mutex_lock(&sshare_lock);
-		sshare->id = swork_id;
+		/* Give the stratum share a unique id */
+		sshare->id = swork_id++;
 		HASH_ADD_INT(stratum_shares, id, sshare);
 		mutex_unlock(&sshare_lock);
 
@@ -2932,7 +2931,7 @@ static void *submit_work_thread(void *userdata)
 		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, swork_id);
+			pool->rpc_user, work->job_id, work->nonce2, work->ntime, noncehex, sshare->id);
 		free(noncehex);
 
 		applog(LOG_INFO, "Submitting share %08lx to pool %d", (unsigned long)(hash32[6]), pool->pool_no);