From: Razvan Becheriu Date: Fri, 14 Nov 2025 09:41:00 +0000 (+0200) Subject: [#4141] reverted X-Git-Tag: Kea-3.1.4~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af177da47d87b18869930695edcb19a0d15e1d85;p=thirdparty%2Fkea.git [#4141] reverted --- diff --git a/config-report.sh.in b/config-report.sh.in index 12e76c3b98..762540ea2f 100755 --- a/config-report.sh.in +++ b/config-report.sh.in @@ -55,6 +55,40 @@ Bison: @BISON@ HERE_DOCUMENT +add_to_report <readReady(fd)); EXPECT_EQ(EBADF, errno); } else if (handler_->type() == FDEventHandler::TYPE_POLL) { - EXPECT_EQ(-1, handler_->waitEvent(0, 1000)); + EXPECT_EQ(1, handler_->waitEvent(0, 1000)); EXPECT_FALSE(handler_->readReady(fd)); EXPECT_EQ(0, errno); } else { diff --git a/src/lib/util/tests/watch_socket_unittests.cc b/src/lib/util/tests/watch_socket_unittests.cc index 97af67217e..685b4ca2e5 100644 --- a/src/lib/util/tests/watch_socket_unittests.cc +++ b/src/lib/util/tests/watch_socket_unittests.cc @@ -119,6 +119,12 @@ TEST(WatchSocketTest, closedWhileReady) { EXPECT_EQ(1, selectCheck(select_fd)); EXPECT_TRUE(watch->isReady()); + // The epoll event handler must be created before closing the socket. + // It creates an internal pipe which will match the closed fd and the + // check for bad file descriptor will fail. + FDEventHandlerPtr handler = FDEventHandlerFactory::factoryFDEventHandler(); + bool use_select = FDEventHandlerFactory::factoryFDEventHandler()->type() != FDEventHandler::TYPE_POLL; + // Interfere by closing the fd. ASSERT_EQ(0, close(select_fd)); @@ -132,7 +138,12 @@ TEST(WatchSocketTest, closedWhileReady) { ASSERT_NO_THROW(watch->clearReady()); // Verify the select_fd fails as socket is invalid/closed. - ASSERT_EQ(-1, selectCheck(select_fd)); + if (use_select) { + ASSERT_EQ(-1, selectCheck(select_fd)); + } else { + handler->add(select_fd); + EXPECT_EQ(1, handler->waitEvent(0, 0)); + } // Verify that subsequent attempts to mark it will fail. ASSERT_THROW(watch->markReady(), WatchSocketError); @@ -191,6 +202,12 @@ TEST(WatchSocketTest, badReadOnClear) { EXPECT_TRUE(watch->isReady()); EXPECT_EQ(1, selectCheck(select_fd)); + // The epoll event handler must be created before closing the socket. + // It creates an internal pipe which will match the closed fd and the + // check for bad file descriptor will fail. + FDEventHandlerPtr handler = FDEventHandlerFactory::factoryFDEventHandler(); + bool use_select = FDEventHandlerFactory::factoryFDEventHandler()->type() != FDEventHandler::TYPE_POLL; + // Interfere by reading the fd. This should empty the read pipe. uint32_t buf = 0; ASSERT_EQ((read (select_fd, &buf, 1)), 1); @@ -203,7 +220,12 @@ TEST(WatchSocketTest, badReadOnClear) { // Verify the select_fd does not evaluate to ready. EXPECT_FALSE(watch->isReady()); - EXPECT_EQ(-1, selectCheck(select_fd)); + if (use_select) { + EXPECT_EQ(-1, selectCheck(select_fd)); + } else { + handler->add(select_fd); + EXPECT_EQ(1, handler->waitEvent(0, 0)); + } // Verify that getSelectFd() returns INVALID. ASSERT_EQ(WatchSocket::SOCKET_NOT_VALID, watch->getSelectFd());