Skip to content
Snippets Groups Projects
Commit 011aef54 authored by Beat Küng's avatar Beat Küng Committed by Daniel Agar
Browse files

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.
parent 9d8015d0
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment