sock: fix EPOLLOUT always reported for outgoing connections

This fixes a bug that caused a socket to be always reported writable
after an outgoing connection was successfully established.
This commit is contained in:
Bert Belder 2018-11-16 12:29:42 -08:00
parent a9e78ad9b5
commit 8b7b340610
No known key found for this signature in database
GPG Key ID: 7A77887B2E2ED461
2 changed files with 2 additions and 3 deletions

View File

@ -13,7 +13,6 @@
#define AFD_POLL_DISCONNECT 0x0008 #define AFD_POLL_DISCONNECT 0x0008
#define AFD_POLL_ABORT 0x0010 #define AFD_POLL_ABORT 0x0010
#define AFD_POLL_LOCAL_CLOSE 0x0020 #define AFD_POLL_LOCAL_CLOSE 0x0020
#define AFD_POLL_CONNECT 0x0040
#define AFD_POLL_ACCEPT 0x0080 #define AFD_POLL_ACCEPT 0x0080
#define AFD_POLL_CONNECT_FAIL 0x0100 #define AFD_POLL_CONNECT_FAIL 0x0100
/* clang-format on */ /* clang-format on */

View File

@ -167,7 +167,7 @@ static inline DWORD sock__epoll_events_to_afd_events(uint32_t epoll_events) {
if (epoll_events & (EPOLLPRI | EPOLLRDBAND)) if (epoll_events & (EPOLLPRI | EPOLLRDBAND))
afd_events |= AFD_POLL_RECEIVE_EXPEDITED; afd_events |= AFD_POLL_RECEIVE_EXPEDITED;
if (epoll_events & (EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND)) if (epoll_events & (EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND))
afd_events |= AFD_POLL_SEND | AFD_POLL_CONNECT; afd_events |= AFD_POLL_SEND;
if (epoll_events & (EPOLLIN | EPOLLRDNORM | EPOLLRDHUP)) if (epoll_events & (EPOLLIN | EPOLLRDNORM | EPOLLRDHUP))
afd_events |= AFD_POLL_DISCONNECT; afd_events |= AFD_POLL_DISCONNECT;
if (epoll_events & EPOLLHUP) if (epoll_events & EPOLLHUP)
@ -185,7 +185,7 @@ static inline uint32_t sock__afd_events_to_epoll_events(DWORD afd_events) {
epoll_events |= EPOLLIN | EPOLLRDNORM; epoll_events |= EPOLLIN | EPOLLRDNORM;
if (afd_events & AFD_POLL_RECEIVE_EXPEDITED) if (afd_events & AFD_POLL_RECEIVE_EXPEDITED)
epoll_events |= EPOLLPRI | EPOLLRDBAND; epoll_events |= EPOLLPRI | EPOLLRDBAND;
if (afd_events & (AFD_POLL_SEND | AFD_POLL_CONNECT)) if (afd_events & AFD_POLL_SEND)
epoll_events |= EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND; epoll_events |= EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND;
if (afd_events & AFD_POLL_DISCONNECT) if (afd_events & AFD_POLL_DISCONNECT)
epoll_events |= EPOLLIN | EPOLLRDNORM | EPOLLRDHUP; epoll_events |= EPOLLIN | EPOLLRDNORM | EPOLLRDHUP;