Skip to content
This repository was archived by the owner on Jun 10, 2022. It is now read-only.
This repository was archived by the owner on Jun 10, 2022. It is now read-only.

nyoci_plat_wait() returns wrong value when timer fires #18

@snej

Description

@snej

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 returns NYOCI_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:

            while (true) {
                if (nyoci_plat_wait(_nyoci, MSEC_PER_SEC) == 0)
                    nyoci_plat_process(_nyoci);
            }

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, then nyoci_handle_timers() should be called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions