Browse Source

bitforce: Ensure bulkqueue polling occurs at least once a second

Luke Dashjr 13 years ago
parent
commit
f0fccf171f
1 changed files with 4 additions and 1 deletions
  1. 4 1
      driver-bitforce.c

+ 4 - 1
driver-bitforce.c

@@ -37,6 +37,7 @@
 #define BITFORCE_MAX_QUEUED 10
 #define BITFORCE_MAX_QRESULTS 10
 #define BITFORCE_GOAL_QRESULTS (BITFORCE_MAX_QRESULTS / 2)
+#define BITFORCE_MAX_QRESULT_WAIT 1000
 
 enum bitforce_proto {
 	BFP_WORK,
@@ -1437,10 +1438,12 @@ bool bitforce_queue_do_results(struct thr_info *thr)
 		return true;
 	}
 	
-	if (count != BITFORCE_GOAL_QRESULTS)
+	if ((count < BITFORCE_GOAL_QRESULTS && bitforce->sleep_ms < BITFORCE_MAX_QRESULT_WAIT) || count > BITFORCE_GOAL_QRESULTS)
 	{
 		unsigned int old_sleep_ms = bitforce->sleep_ms;
 		bitforce->sleep_ms = (uint32_t)bitforce->sleep_ms * BITFORCE_GOAL_QRESULTS / (count ?: 1);
+		if (bitforce->sleep_ms > BITFORCE_MAX_QRESULT_WAIT)
+			bitforce->sleep_ms = BITFORCE_MAX_QRESULT_WAIT;
 		applog(LOG_DEBUG, "%"PRIpreprv": Received %d queue results after %ums; Wait time changed to: %ums",
 		       bitforce->proc_repr, count, old_sleep_ms, bitforce->sleep_ms);
 	}