Commit c9c8022f62349bc4b1ff5c8bec1168bd6b7361a0

Angus Gratton 2014-02-26T13:26:32

Drillbit: Limit work sent out to 8 units in a single pass, was DoSing a full double scroll

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/driver-drillbit.c b/driver-drillbit.c
index 10d1a4e..0c7ef38 100644
--- a/driver-drillbit.c
+++ b/driver-drillbit.c
@@ -854,13 +854,14 @@ static int64_t drillbit_scanwork(struct thr_info *thr)
 	struct drillbit_info *info = drillbit->device_data;
 	struct drillbit_chip_info *chip;
 	struct timeval tv_now;
-	int amount, i, j, ms_diff, result_count = 0;;
+	int amount, i, j, ms_diff, result_count = 0, sent_count = 0;;
 	char buf[200];
 
 	/* send work to an any chip without queued work */
-	for (i = 0; i < info->num_chips; i++) {
+	for (i = 0; i < info->num_chips && sent_count < 8; i++) {
 		if (info->chips[i].state != WORKING_QUEUED) {
 			drillbit_send_work_to_chip(thr, &info->chips[i]);
+			sent_count++;
 		}
 		if (unlikely(thr->work_restart) || unlikely(drillbit->usbinfo.nodev))
 			goto cascade;