-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Currently, the EpollNetProvider's wait method returns errors (while the LibevNetProvider does not):
tntcxx/src/Client/EpollNetProvider.hpp
Lines 276 to 281 in a3d0414
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; | |
} |
tntcxx/src/Client/EpollNetProvider.hpp
Lines 288 to 299 in a3d0414
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; |
tntcxx/src/Client/EpollNetProvider.hpp
Lines 308 to 315 in a3d0414
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:
tntcxx/src/Client/Connector.hpp
Lines 229 to 233 in a3d0414
if (m_NetProvider.wait(timer.timeLeft()) != 0) { | |
conn.setError(std::string("Failed to poll: ") + | |
strerror(errno), errno); | |
return -1; | |
} |
tntcxx/src/Client/Connector.hpp
Lines 269 to 273 in a3d0414
if (m_NetProvider.wait(timer.timeLeft()) != 0) { | |
conn.setError(std::string("Failed to poll: ") + | |
strerror(errno), errno); | |
return -1; | |
} |
tntcxx/src/Client/Connector.hpp
Lines 328 to 332 in a3d0414
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.