Skip to content

Commit

Permalink
xxx
Browse files Browse the repository at this point in the history
  • Loading branch information
LDVG committed Jan 29, 2025
1 parent f353eb8 commit 8a517fa
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/hid_osx.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ fido_hid_read(void *handle, unsigned char *buf, size_t len, int ms)
{
struct hid_osx *ctx = handle;
ssize_t r;
struct timespec ts;

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

/* check for pending frame */
if ((r = read(ctx->report_pipe[0], buf, len)) == -1) {
if (errno != EAGAIN && errno != EWOULDBLOCK) {
fido_log_error(errno, "%s: read", __func__);
return (-1);
}

schedule_io_loop(ctx, ms);
if (fido_time_now(&ts) != 0) {
fido_log_debug("%s: fido_time_now", __func__);
return (-1);
}

if ((r = read(ctx->report_pipe[0], buf, len)) == -1) {
do {
if ((r = read(ctx->report_pipe[0], buf, len)) >= 0)
break;
if (errno != EAGAIN && errno != EWOULDBLOCK) {
fido_log_error(errno, "%s: read", __func__);
return (-1);
}
}
schedule_io_loop(ctx, ms > 100 ? 100 : ms);
} while (fido_time_delta(&ts, &ms) == 0);

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

0 comments on commit 8a517fa

Please sign in to comment.