Skip to content

Timeout in connector seems to be dangerously implemented #128

@drewdzzz

Description

@drewdzzz

In all wait methods we firstly check if the timer is not expired and then pass timeout - timer.elapsed() to wait of NetProvider. The wait of NetProvider expects a positive number (or -1 as infinity), but timeout - timer.elapsed() can actually be negative: for example, OS can reschedule the process right after timer.isExpired() call, so it will be actually expired when NetPovider.wait is called.

while (!conn.hasError() && !conn.futureIsReady(future) &&
!timer.isExpired()) {
if (m_NetProvider.wait(timeout - timer.elapsed()) != 0) {
conn.setError(std::string("Failed to poll: ") +
strerror(errno), errno);
return -1;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions