The cpu mining work data can get modified before we copy it if we submit it async, and the sync submission is not truly sync anyway, so just submit it sync.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
diff --git a/main.c b/main.c
index 6f45dc6..6e46178 100644
--- a/main.c
+++ b/main.c
@@ -3243,42 +3243,6 @@ err_out:
return false;
}
-struct swa {
- struct thr_info *thr;
- const struct work *work_in;
-};
-
-static void *swasync_thread(void *userdata)
-{
- struct swa *swa = (struct swa *)userdata;
-
- /* Return value ignored */
- submit_work_sync(swa->thr, swa->work_in);
- free(swa);
- return NULL;
-}
-
-static bool submit_work_async(struct thr_info *thr, const struct work *work_in)
-{
- pthread_t sw_thread;
- struct swa *swa;
-
- swa = malloc(sizeof(struct swa));
- if (unlikely(!swa)) {
- applog(LOG_ERR, "Failed to malloc swa in submit_work_async");
- return false;
- }
-
- swa->thr = thr;
- swa->work_in = work_in;
-
- if (unlikely(pthread_create(&sw_thread, NULL, swasync_thread, (void *)swa))) {
- applog(LOG_ERR, "Failed to create swasync_thread");
- return false;
- }
- return true;
-}
-
bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
{
work->data[64+12+0] = (nonce>>0) & 0xff;
@@ -3469,7 +3433,7 @@ static void *miner_thread(void *userdata)
if (unlikely(rc)) {
if (opt_debug)
applog(LOG_DEBUG, "CPU %d found something?", dev_from_id(thr_id));
- if (unlikely(!submit_work_async(mythr, work))) {
+ if (unlikely(!submit_work_sync(mythr, work))) {
applog(LOG_ERR, "Failed to submit_work_sync in miner_thread %d", thr_id);
break;
}