Skip to content

Commit 8a517fa

Browse files
committed
xxx
1 parent f353eb8 commit 8a517fa

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/hid_osx.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ fido_hid_read(void *handle, unsigned char *buf, size_t len, int ms)
543543
{
544544
struct hid_osx *ctx = handle;
545545
ssize_t r;
546+
struct timespec ts;
546547

547548
explicit_bzero(buf, len);
548549
explicit_bzero(ctx->report, sizeof(ctx->report));
@@ -552,20 +553,20 @@ fido_hid_read(void *handle, unsigned char *buf, size_t len, int ms)
552553
return (-1);
553554
}
554555

555-
/* check for pending frame */
556-
if ((r = read(ctx->report_pipe[0], buf, len)) == -1) {
557-
if (errno != EAGAIN && errno != EWOULDBLOCK) {
558-
fido_log_error(errno, "%s: read", __func__);
559-
return (-1);
560-
}
561-
562-
schedule_io_loop(ctx, ms);
556+
if (fido_time_now(&ts) != 0) {
557+
fido_log_debug("%s: fido_time_now", __func__);
558+
return (-1);
559+
}
563560

564-
if ((r = read(ctx->report_pipe[0], buf, len)) == -1) {
561+
do {
562+
if ((r = read(ctx->report_pipe[0], buf, len)) >= 0)
563+
break;
564+
if (errno != EAGAIN && errno != EWOULDBLOCK) {
565565
fido_log_error(errno, "%s: read", __func__);
566566
return (-1);
567567
}
568-
}
568+
schedule_io_loop(ctx, ms > 100 ? 100 : ms);
569+
} while (fido_time_delta(&ts, &ms) == 0);
569570

570571
if (r < 0 || (size_t)r != len) {
571572
fido_log_debug("%s: %zd != %zu", __func__, r, len);

0 commit comments

Comments
 (0)