Fix overflow in get_deadline for large (>2000ms) timeouts
This commit is contained in:
parent
265055106b
commit
b4acf08738
3
util.c
3
util.c
|
|
@ -93,7 +93,8 @@ void normalize_timespec(struct timespec *ts)
|
||||||
void get_deadline(uint32_t timeout_ms, struct timespec *ts)
|
void get_deadline(uint32_t timeout_ms, struct timespec *ts)
|
||||||
{
|
{
|
||||||
clock_gettime(CLOCK_REALTIME, ts);
|
clock_gettime(CLOCK_REALTIME, ts);
|
||||||
ts->tv_nsec += timeout_ms * 1000000;
|
ts->tv_sec += timeout_ms / 1000;
|
||||||
|
ts->tv_nsec += (timeout_ms % 1000) * 1000000;
|
||||||
normalize_timespec(ts);
|
normalize_timespec(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue