From 4c9171792b8005c32dd431e19f804167564ba1be Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 15 Jul 2011 09:48:26 +1000 Subject: [PATCH] Limit the number of work items we put in the queue. --- main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 77668b12..7390646a 100644 --- a/main.c +++ b/main.c @@ -1147,6 +1147,11 @@ static bool queue_request(void) struct thr_info *thr = &thr_info[0]; struct workio_cmd *wc; + /* If we've been generating lots of local work we may already have + * enough in the queue */ + if (requests_queued() >= opt_queue + mining_threads) + return true; + /* fill out work request message */ wc = calloc(1, sizeof(*wc)); if (unlikely(!wc)) { @@ -1163,6 +1168,7 @@ static bool queue_request(void) workio_cmd_free(wc); return false; } + getwork_requested++; inc_queued(); return true; } @@ -1233,8 +1239,6 @@ static bool get_work(struct work *work, bool queued) bool ret = false; int failures = 0; - getwork_requested++; - retry: if (unlikely(!queued && !queue_request())) { applog(LOG_WARNING, "Failed to queue_request in get_work");