diff options
author | Maxim Yurchuk <maxim-yurchuk@ydb.tech> | 2024-11-20 17:37:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-20 17:37:57 +0000 |
commit | f76323e9b295c15751e51e3443aa47a36bee8023 (patch) | |
tree | 4113c8cad473a33e0f746966e0cf087252fa1d7a /util/network/socket.cpp | |
parent | 753ecb8d410a4cb459c26f3a0082fb2d1724fe63 (diff) | |
parent | a7b9a6afea2a9d7a7bfac4c5eb4c1a8e60adb9e6 (diff) | |
download | ydb-f76323e9b295c15751e51e3443aa47a36bee8023.tar.gz |
Merge pull request #11788 from ydb-platform/mergelibs-241120-1113
Library import 241120-1113
Diffstat (limited to 'util/network/socket.cpp')
-rw-r--r-- | util/network/socket.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/util/network/socket.cpp b/util/network/socket.cpp index 0d86ceadfd..ba9c3f7d42 100644 --- a/util/network/socket.cpp +++ b/util/network/socket.cpp @@ -110,15 +110,18 @@ static int convert_events(int events, const evpair* evpairs, size_t nevpairs, bo if (events & event) { events ^= event; long winEvent = evpairs[i].winevent; - if (winEvent == -1) + if (winEvent == -1) { return -1; - if (winEvent == 0) + } + if (winEvent == 0) { continue; + } result |= winEvent; } } - if (events != 0 && !ignoreUnknown) + if (events != 0 && !ignoreUnknown) { return -1; + } return result; } @@ -199,12 +202,13 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept { HANDLE events[] = {event.Get()}; DWORD wait_result = WSAWaitForMultipleEvents(1, events, TRUE, timeout, FALSE); - if (wait_result == WSA_WAIT_TIMEOUT) + if (wait_result == WSA_WAIT_TIMEOUT) { return 0; - else if (wait_result == WSA_WAIT_EVENT_0) { + } else if (wait_result == WSA_WAIT_EVENT_0) { for (pollfd* fd = fds; fd < fds + nfds; ++fd) { - if (fd->revents == POLLNVAL) + if (fd->revents == POLLNVAL) { continue; + } WSANETWORKEVENTS network_events; if (WSAEnumNetworkEvents(fd->fd, event.Get(), &network_events)) { errno = EIO; @@ -217,8 +221,9 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept { break; } } - if (fd->revents == POLLERR) + if (fd->revents == POLLERR) { continue; + } if (network_events.lNetworkEvents) { fd->revents = static_cast<short>(convert_events(network_events.lNetworkEvents, evpairs_to_unix, nevpairs_to_unix, true)); if (fd->revents & POLLHUP) { @@ -227,9 +232,11 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout) noexcept { } } int chanded_sockets = 0; - for (pollfd* fd = fds; fd < fds + nfds; ++fd) - if (fd->revents != 0) + for (pollfd* fd = fds; fd < fds + nfds; ++fd) { + if (fd->revents != 0) { ++chanded_sockets; + } + } return chanded_sockets; } else { errno = EIO; |