diff options
author | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
commit | 31773f157bf8164364649b5f470f52dece0a4317 (patch) | |
tree | 33d0f7eef45303ab68cf08ab381ce5e5e36c5240 /util/network/socket.cpp | |
parent | 2c7938962d8689e175574fc1e817c05049f27905 (diff) | |
parent | eff600952d5dfe17942f38f510a8ac2b203bb3a5 (diff) | |
download | ydb-31773f157bf8164364649b5f470f52dece0a4317.tar.gz |
Merge branch 'rightlib' into mergelibs-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; |