Commit 4c9171792b8005c32dd431e19f804167564ba1be

Con Kolivas 2011-07-15T09:48:26

Limit the number of work items we put in the queue.

diff --git a/main.c b/main.c
index 77668b1..7390646 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");