From 998d8d45f4baffe712f1ca616dc809e5364cbb08 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 30 Jun 2011 11:30:37 +1000 Subject: [PATCH] Postcalc hash is already its own thread so work can be submitted synchronously from that. --- cpu-miner.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/cpu-miner.c b/cpu-miner.c index c87ecab8..0290c6d9 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -700,13 +700,46 @@ static bool submit_work_async(struct thr_info *thr, const struct work *work_in) return true; } +static bool submit_work_sync(struct thr_info *thr, const struct work *work_in) +{ + struct workio_cmd *wc; + + /* fill out work request message */ + wc = calloc(1, sizeof(*wc)); + if (unlikely(!wc)) { + applog(LOG_ERR, "Failed to calloc wc in submit_work_sync"); + return false; + } + + wc->u.work = malloc(sizeof(*work_in)); + if (unlikely(!wc->u.work)) { + applog(LOG_ERR, "Failed to calloc work in submit_work_sync"); + goto err_out; + } + + wc->cmd = WC_SUBMIT_WORK; + wc->thr = thr; + memcpy(wc->u.work, work_in, sizeof(*work_in)); + + /* send solution to workio thread */ + if (unlikely(!tq_push(thr_info[work_thr_id].q, wc))) { + applog(LOG_ERR, "Failed to tq_push work in submit_work_sync"); + goto err_out; + } + + return true; +err_out: + workio_cmd_free(wc); + return false; +} + bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce) { work->data[64+12+0] = (nonce>>0) & 0xff; work->data[64+12+1] = (nonce>>8) & 0xff; work->data[64+12+2] = (nonce>>16) & 0xff; work->data[64+12+3] = (nonce>>24) & 0xff; - return submit_work_async(thr, work); + return submit_work_sync(thr, work); } static inline int cpu_from_thr_id(int thr_id)