mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
px4_poll posix: fix wrap-around for large timeouts
timeout is an int, so it wraps when the poll timeout is >2147ms. This happened in logger, resulting in poll never returning.
This commit is contained in:
parent
9d8015d029
commit
011aef5464
@ -377,7 +377,7 @@ extern "C" {
|
||||
|
||||
// Calculate an absolute time in the future
|
||||
const unsigned billion = (1000 * 1000 * 1000);
|
||||
uint64_t nsecs = ts.tv_nsec + (timeout * 1000 * 1000);
|
||||
uint64_t nsecs = ts.tv_nsec + ((uint64_t)timeout * 1000 * 1000);
|
||||
ts.tv_sec += nsecs / billion;
|
||||
nsecs -= (nsecs / billion) * billion;
|
||||
ts.tv_nsec = nsecs;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user