mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-17 11:27:34 +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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user