Skip to content

Commit

Permalink
sysoff: Retry on EBUSY when probing supported ioctls.
Browse files Browse the repository at this point in the history
Handle EBUSY when probing support for a PTP_SYS_OFFSET ioctl. Try each
ioctl up to three times before giving up on it to make the detection
more reliable.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
  • Loading branch information
mlichvar authored and richardcochran committed Jul 24, 2022
1 parent 2707093 commit dadd259
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions sysoff.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ int sysoff_measure(int fd, int method, int n_samples,
int sysoff_probe(int fd, int n_samples)
{
int64_t junk, delay;
int i, j, err;
uint64_t ts;
int i;

if (n_samples > PTP_MAX_SAMPLES) {
fprintf(stderr, "warning: %d exceeds kernel max readings %d\n",
Expand All @@ -156,9 +156,15 @@ int sysoff_probe(int fd, int n_samples)
}

for (i = 0; i < SYSOFF_LAST; i++) {
if (sysoff_measure(fd, i, n_samples, &junk, &ts, &delay) < 0)
continue;
return i;
for (j = 0; j < 3; j++) {
err = sysoff_measure(fd, i, n_samples, &junk, &ts,
&delay);
if (err == -EBUSY)
continue;
if (err)
break;
return i;
}
}

return SYSOFF_RUN_TIME_MISSING;
Expand Down

0 comments on commit dadd259

Please sign in to comment.