diff options
author | kulikov <kulikov@yandex-team.com> | 2022-11-14 16:35:19 +0300 |
---|---|---|
committer | kulikov <kulikov@yandex-team.com> | 2022-11-14 16:35:19 +0300 |
commit | 7c3d98b1daa4cb8b077d748f4e2d1d5ab042a9c1 (patch) | |
tree | ca793d6e7c38e48be4bbf05715ad3738b1595328 /util/network | |
parent | f3a41eeecd133b98231d8990f887fa7ddffb74d7 (diff) | |
download | ydb-7c3d98b1daa4cb8b077d748f4e2d1d5ab042a9c1.tar.gz |
more information in TEpollPoller::SetImpl error messages
- don't hide epoll_ctl add errors;
- print "fd" and "what" args.
Diffstat (limited to 'util/network')
-rw-r--r-- | util/network/poller_ut.cpp | 7 | ||||
-rw-r--r-- | util/network/pollerimpl.h | 12 |
2 files changed, 17 insertions, 2 deletions
diff --git a/util/network/poller_ut.cpp b/util/network/poller_ut.cpp index 6df0dda8ec..e5914b7df3 100644 --- a/util/network/poller_ut.cpp +++ b/util/network/poller_ut.cpp @@ -232,5 +232,12 @@ Y_UNIT_TEST_SUITE(TSocketPollerTest) { UNIT_ASSERT_EQUAL(TPoller::ExtractFilter(&e), CONT_POLL_RDHUP); UNIT_ASSERT_EQUAL(TPoller::ExtractEvent(&e), (void*)17); } + + Y_UNIT_TEST(TestSetSocketErrors) { + TGenericPoller<TEpollPoller<TWithoutLocking>> poller; + + UNIT_ASSERT_EXCEPTION_CONTAINS(poller.Set(nullptr, Max<int>(), CONT_POLL_READ), TSystemError, "epoll add failed"); + UNIT_ASSERT_EXCEPTION_CONTAINS(poller.Set(nullptr, Max<int>(), CONT_POLL_READ | CONT_POLL_MODIFY), TSystemError, "epoll modify failed"); + } #endif } diff --git a/util/network/pollerimpl.h b/util/network/pollerimpl.h index 21534967fa..0ec45e24f2 100644 --- a/util/network/pollerimpl.h +++ b/util/network/pollerimpl.h @@ -251,9 +251,17 @@ public: e.data.ptr = data; - if ((what & CONT_POLL_MODIFY) || epoll_ctl(Fd_, EPOLL_CTL_ADD, fd, &e) == -1) { + if (what & CONT_POLL_MODIFY) { if (epoll_ctl(Fd_, EPOLL_CTL_MOD, fd, &e) == -1) { - ythrow TSystemError() << "epoll add failed"; + ythrow TSystemError() << "epoll modify failed (fd=" << fd << ", what=" << what << ")"; + } + } else if (epoll_ctl(Fd_, EPOLL_CTL_ADD, fd, &e) == -1) { + if (LastSystemError() != EEXIST) { + ythrow TSystemError() << "epoll add failed (fd=" << fd << ", what=" << what << ")"; + } + + if (epoll_ctl(Fd_, EPOLL_CTL_MOD, fd, &e) == -1) { + ythrow TSystemError() << "epoll modify failed (fd=" << fd << ", what=" << what << ")"; } } } |