There is still potential for an uneven number of queued and dropped work items with this unnecessarily complex check. Flush work guarantees a symmetrical number of queue and discard already.
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
diff --git a/main.c b/main.c
index 4383c9a..1d803ac 100644
--- a/main.c
+++ b/main.c
@@ -771,8 +771,8 @@ static bool get_work(struct work *work, bool queued)
struct work *work_heap;
bool ret = false;
- if (!queued || !requests_queued()) {
- if (unlikely(!queue_request()))
+ if (unlikely(!queued && !queue_request())) {
+ applog(LOG_ERR, "Failed to queue_request in get_work");
goto out;
}
@@ -869,16 +869,6 @@ static void *miner_thread(void *userdata)
bool rc;
if (needs_work) {
- if (work_restart[thr_id].restart) {
- if (requested) {
- /* We have one extra request than desired now */
- if (unlikely(!discard_request())) {
- applog(LOG_ERR, "Failed to discard request in uminer thread");
- goto out;
- }
- } else
- requested = true;
- }
gettimeofday(&tv_workstart, NULL);
/* obtain new work from internal workio thread */
if (unlikely(!get_work(&work, requested))) {
@@ -1118,16 +1108,6 @@ static void *gpuminer_thread(void *userdata)
memset(res, 0, BUFFERSIZE);
gettimeofday(&tv_workstart, NULL);
- if (work_restart[thr_id].restart) {
- if (requested) {
- /* We have one extra request than desired now */
- if (unlikely(!discard_request())) {
- applog(LOG_ERR, "Failed to discard request in gpuminer thread");
- goto out;
- }
- } else
- requested = true;
- }
/* obtain new work from internal workio thread */
if (unlikely(!get_work(work, requested))) {
applog(LOG_ERR, "work retrieval failed, exiting "