Skip to content

NetProvider.wait should not explicitly return errors #141

@CuriousGeorgiy

Description

@CuriousGeorgiy

Currently, the EpollNetProvider's wait method returns errors (while the LibevNetProvider does not):

if (event_cnt < 0) {
//Poll error doesn't belong to any connection so just global
//log it.
LOG_ERROR("Poll failed: ", strerror(errno));
return -1;
}

if (conn.get_strm().has_status(SS_NEED_READ_EVENT_FOR_WRITE)) {
int rc = send(conn);
if (rc < 0)
return -1;
}
/*
* Once we read all bytes from socket connection
* becomes ready to decode.
*/
int rc = recv(conn);
if (rc < 0)
return -1;

if (conn.get_strm().has_status(SS_NEED_WRITE_EVENT_FOR_READ)) {
int rc = recv(conn);
if (rc < 0)
return -1;
}
int rc = send(conn);
if (rc < 0)
return -1;

However, since the NetProvider manages multiple connections the fact it returns an error when we are waiting for one specific connection is ambiguous. It is not clear how to handle the error on the connector level. Moreover, setting an error for a specific connection based on the wait failure, as we currently do, is obviously wrong:

if (m_NetProvider.wait(timer.timeLeft()) != 0) {
conn.setError(std::string("Failed to poll: ") +
strerror(errno), errno);
return -1;
}

if (m_NetProvider.wait(timer.timeLeft()) != 0) {
conn.setError(std::string("Failed to poll: ") +
strerror(errno), errno);
return -1;
}

if (m_NetProvider.wait(timer.timeLeft()) != 0) {
conn.setError(std::string("Failed to poll: ") +
strerror(errno), errno);
return -1;
}

Instead, we should rely on the NetProvider to mark any connection as faulty, and the NetProvider should be able to overcome any failures internally, like the LibevNetProvider does.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions