Skip to content

Commit

Permalink
isotest: Fix not calculating time to wait
Browse files Browse the repository at this point in the history
The difference of time start and current time may have advanced just
enough to add a second leaving start nanoseconds to be bigger.
  • Loading branch information
Vudentz committed Dec 9, 2022
1 parent e07c1e7 commit 3d6e4bf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/isotest.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,10 @@ static void send_wait(struct timespec *t_start, uint32_t us)
}

t_diff.tv_sec = t_now.tv_sec - t_start->tv_sec;
if (t_start->tv_nsec > t_now.tv_nsec) {
t_diff.tv_sec--;
t_now.tv_nsec += 1000000000L;
}
t_diff.tv_nsec = t_now.tv_nsec - t_start->tv_nsec;

delta_us = us - TS_USEC(&t_diff);
Expand Down

0 comments on commit 3d6e4bf

Please sign in to comment.