From 17ba2dca63fdef062c63b8532b9ec7fdedd57caa Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 25 Jun 2012 10:51:45 +1000 Subject: [PATCH] Logic fail on queueing multiple requests at once. Just queue one at a time. --- cgminer.c | 55 +++++++++++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/cgminer.c b/cgminer.c index a186ff14..a6232a46 100644 --- a/cgminer.c +++ b/cgminer.c @@ -3550,7 +3550,7 @@ static bool queue_request(struct thr_info *thr, bool needed) struct workio_cmd *wc; struct timeval now; time_t scan_post; - int toq, rq, rs; + int rq, rs; bool ret = true; /* Prevent multiple requests being executed at once */ @@ -3577,42 +3577,33 @@ static bool queue_request(struct thr_info *thr, bool needed) requested_tv_sec = now.tv_sec; - if (rq > rs) - toq = rq - mining_threads; - else - toq = rs - mining_threads; + inc_queued(); - do { - inc_queued(); - - /* fill out work request message */ - wc = calloc(1, sizeof(*wc)); - if (unlikely(!wc)) { - applog(LOG_ERR, "Failed to calloc wc in queue_request"); - ret = false; - break; - } - - wc->cmd = WC_GET_WORK; - wc->thr = thr; + /* fill out work request message */ + wc = calloc(1, sizeof(*wc)); + if (unlikely(!wc)) { + applog(LOG_ERR, "Failed to calloc wc in queue_request"); + ret = false; + goto out; + } - /* If we're queueing work faster than we can stage it, consider the - * system lagging and allow work to be gathered from another pool if - * possible */ - if (rq && needed && !rs && !opt_fail_only) - wc->lagging = true; + wc->cmd = WC_GET_WORK; + wc->thr = thr; - applog(LOG_DEBUG, "Queueing getwork request to work thread"); + /* If we're queueing work faster than we can stage it, consider the + * system lagging and allow work to be gathered from another pool if + * possible */ + if (rq && needed && !rs && !opt_fail_only) + wc->lagging = true; - /* send work request to workio thread */ - if (unlikely(!tq_push(thr_info[work_thr_id].q, wc))) { - applog(LOG_ERR, "Failed to tq_push in queue_request"); - workio_cmd_free(wc); - ret = false; - break; - } + applog(LOG_DEBUG, "Queueing getwork request to work thread"); - } while (--toq > 0); + /* send work request to workio thread */ + if (unlikely(!tq_push(thr_info[work_thr_id].q, wc))) { + applog(LOG_ERR, "Failed to tq_push in queue_request"); + workio_cmd_free(wc); + ret = false; + } out: control_tclear(&queueing);