Fixed connect(2) errors processing on old Linuxes.

While connect(2) states that non-blocking connect should use EPOLLOUT:

  EINPROGRESS
    The socket is non-blocking and the connection cannot be completed
    immediately.  It is possible to select(2) or poll(2) for completion by
    selecting the socket for writing.  After select(2) indicates writability,
    use getsockopt(2) to read the SO_ERROR option at level SOL_SOCKET to
    determine whether connect() completed successfully (SO_ERROR is zero)
    or unsuccessfully (SO_ERROR is one of the usual error codes listed here,
    explaining the reason for the failure).

On connect error, Linux 2.6.32 (CentOS 6) may return EPOLLRDHUP, EPOLLERR,
EPOLLHUP, EPOLLIN, but not EPOLLOUT.
This commit is contained in:
Igor Sysoev
2019-11-14 16:39:48 +03:00
parent 5452ee458d
commit 96cd6558ce
4 changed files with 61 additions and 30 deletions

View File

@@ -106,6 +106,7 @@ NXT_EXPORT nxt_int_t nxt_socket_connect(nxt_task_t *task, nxt_socket_t s,
nxt_sockaddr_t *sa);
NXT_EXPORT void nxt_socket_shutdown(nxt_task_t *task, nxt_socket_t s,
nxt_uint_t how);
nxt_err_t nxt_socket_error(nxt_socket_t s);
nxt_uint_t nxt_socket_error_level(nxt_err_t err);
NXT_EXPORT nxt_int_t nxt_socketpair_create(nxt_task_t *task,