Browse Source

Bugfix: bitforce_queue: Implement a minimum wait time of 10ms

Luke Dashjr 12 years ago
parent
commit
d65d47e54b
1 changed files with 5 additions and 1 deletions
  1. 5 1
      driver-bitforce.c

+ 5 - 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_MIN_QRESULT_WAIT BITFORCE_CHECK_INTERVAL_MS
 #define BITFORCE_MAX_QRESULT_WAIT 1000
 
 enum bitforce_proto {
@@ -1486,12 +1487,15 @@ next_qline: (void)0;
 	
 	bitforce_set_queue_full(thr);
 	
-	if ((count < BITFORCE_GOAL_QRESULTS && bitforce->sleep_ms < BITFORCE_MAX_QRESULT_WAIT && data->queued > 1) || count > BITFORCE_GOAL_QRESULTS)
+	if ((count < BITFORCE_GOAL_QRESULTS && bitforce->sleep_ms < BITFORCE_MAX_QRESULT_WAIT && data->queued > 1)
+	 || (count > BITFORCE_GOAL_QRESULTS && bitforce->sleep_ms > BITFORCE_MIN_QRESULT_WAIT))
 	{
 		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;
+		if (bitforce->sleep_ms < BITFORCE_MIN_QRESULT_WAIT)
+			bitforce->sleep_ms = BITFORCE_MIN_QRESULT_WAIT;
 		applog(LOG_DEBUG, "%"PRIpreprv": Received %d queue results after %ums; Wait time changed to: %ums (queued<=%d)",
 		       bitforce->proc_repr, count, old_sleep_ms, bitforce->sleep_ms, data->queued);
 	}