Skip to content

Commit

Permalink
timemaster: Wait for udev to set up vclock devices.
Browse files Browse the repository at this point in the history
timemaster created vclock /dev/ptp devices (by writing to
/sys/class/ptp/ptp?/n_vclocks) and immediately started ptp4l
instances using those vclocks. It's a race condition. On a
SELinux-enabled system ptp4l was observed to exit with an error due to
the device not having its SELinux context set by udev yet.

Add a 100-millisecond sleep after creating the vclocks to give udev time
to finish its job before starting ptp4l instances.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
  • Loading branch information
mlichvar authored and richardcochran committed Sep 4, 2024
1 parent 3cf1795 commit 0f8ff22
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions timemaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -1240,12 +1240,18 @@ static int create_vclocks(struct phc_vclocks **phc_vclocks)
{
struct phc_vclocks **vclocks;

if (!*phc_vclocks)
return 0;

for (vclocks = phc_vclocks; *vclocks; vclocks++) {
if (set_phc_n_vclocks((*vclocks)->pclock_index,
(*vclocks)->vclocks))
return 1;
}

/* Wait for udev to set up the new /dev/ptp* devices */
usleep(100000);

return 0;
}

Expand Down

0 comments on commit 0f8ff22

Please sign in to comment.