Open snej opened 6 years ago
Good catch!
NYOCI_STATUS_TIMEOUT
should only be returned if the actual call timed out, not if a timer fired—that should just return NYOCI_STATUS_OK
(zero).
Happy to take a patch, otherwise it may be a week or two before I can get to this.
The header doc for
nyoci_plat_wait()
says "it returns 0 if nyoci_plat_process() should be executed". The POSIX implementation doesn't quite agree with this: it does return 0 if a file descriptor has input, but it returnsNYOCI_STATUS_TIMEOUT
if a timer is ready to fire. Thus, a loop like this one won't work because it never handles timers until a packet arrives:This happens because the function doesn't distinguish whether it's the timeout given by the caller that's elapsed, or the timeout till the next timer. In the latter case it should return 0.
Alternatively, the docs could be amended to match the implementation, by saying that if the function returns
NYOCI_STATUS_TIMEOUT
, thennyoci_handle_timers()
should be called.