fixes #38
it seems there is a race if a fast computer makes control transfers
very close to each other in time, this enforces a 10ms sleep at the
start of a read.
slot = 0;
while (slept_time < max_time_ms) {
+ Sleep(sleepval);
+ slept_time += sleepval;
+ /* exponential backoff, up to 500 ms */
+ sleepval *= 2;
+ if (sleepval > 500)
+ sleepval = 500;
+
/* Read a status report from the key */
memset(data, 0, sizeof(data));
if (!_ykusb_read(yk, REPORT_TYPE_FEATURE, slot, (char *) &data, FEATURE_RPT_SIZE))
break;
}
}
-
- Sleep(sleepval);
- slept_time += sleepval;
- /* exponential backoff, up to 500 ms */
- sleepval *= 2;
- if (sleepval > 500)
- sleepval = 500;
}
yk_errno = YK_ETIMEOUT;