From 3cfa7e8f69ecb6829072f4368b8b6b524e999289 Mon Sep 17 00:00:00 2001 From: Alexander Rutkovsky Date: Thu, 28 Dec 2023 08:20:39 +0000 Subject: [PATCH] Fix poller compatibility mode KIKIMR-20604 --- .../actors/interconnect/poller_actor_linux.h | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ydb/library/actors/interconnect/poller_actor_linux.h b/ydb/library/actors/interconnect/poller_actor_linux.h index 2cd557e347a3..a6f2ebf73121 100644 --- a/ydb/library/actors/interconnect/poller_actor_linux.h +++ b/ydb/library/actors/interconnect/poller_actor_linux.h @@ -80,24 +80,24 @@ namespace NActors { static constexpr ui32 fullWrite = WriteExpected | WriteHit; bool read = (updated & fullRead) == fullRead; bool write = (updated & fullWrite) == fullWrite; + if (checkQueues) { + const bool queryRead = updated & ReadExpected && !read; + const bool queryWrite = updated & WriteExpected && !write; + if (queryRead || queryWrite) { + pollfd fd; + fd.fd = record->Socket->GetDescriptor(); + fd.events = (queryRead ? POLLIN | POLLRDHUP : 0) | (queryWrite ? POLLOUT : 0); + if (poll(&fd, 1, 0) != -1) { + read |= queryRead && fd.revents & (POLLIN | POLLHUP | POLLRDHUP | POLLERR); + write |= queryWrite && fd.revents & (POLLOUT | POLLERR); + } + } + } updated &= ~((read ? fullRead : 0) | (write ? fullWrite : 0)); if (record->Flags.compare_exchange_weak(flags, updated, std::memory_order_acq_rel)) { if (suppressNotify) { return read || write; } else { - if (checkQueues) { - pollfd fd; - fd.fd = record->Socket->GetDescriptor(); - const bool queryRead = updated & ReadExpected && !read; - const bool queryWrite = updated & WriteExpected && !write; - if (queryRead || queryWrite) { - fd.events = (queryRead ? POLLIN : 0) | (queryWrite ? POLLOUT : 0); - if (poll(&fd, 1, 0) != -1) { - read = queryRead && fd.revents & (POLLIN | POLLHUP | POLLRDHUP | POLLERR); - write = queryWrite && fd.revents & (POLLOUT | POLLERR); - } - } - } Notify(record, read, write); return false; }