Commit 03abb704673d97d365dcd2df086ff24931ba0daf

Con Kolivas 2012-04-27T13:59:43

Use longpolls from backup pools with failover-only enabled just to check for block changes, but don't use them as work.

diff --git a/cgminer.c b/cgminer.c
index 0e6be11..e78fe70 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -3798,10 +3798,6 @@ static void convert_to_work(json_t *val, bool rolltime, struct pool *pool)
 	struct work *work, *work_clone;
 	bool rc;
 
-	/* Don't use as work if we have failover-only enabled */
-	if (pool != cp && opt_fail_only)
-		return;
-
 	work = make_work();
 
 	rc = work_decode(json_object_get(val, "result"), work);
@@ -3814,7 +3810,7 @@ static void convert_to_work(json_t *val, bool rolltime, struct pool *pool)
 	work->rolltime = rolltime;
 
 	/* Only flag this as longpoll work if the pool is the current pool */
-	if (pool == cp)
+	if (pool == current_pool())
 		work->longpoll = true;
 
 	/* We'll be checking this work item twice, but we already know it's
@@ -3823,6 +3819,12 @@ static void convert_to_work(json_t *val, bool rolltime, struct pool *pool)
 	 * allows testwork to know whether LP discovered the block or not. */
 	test_work_current(work);
 
+	/* Don't use as work if we have failover-only enabled */
+	if (!work->longpoll && opt_fail_only) {
+		free_work(work);
+		return;
+	}
+
 	work_clone = make_work();
 	memcpy(work_clone, work, sizeof(struct work));
 	while (reuse_work(work)) {