From: Razvan Becheriu Date: Wed, 19 Nov 2025 12:25:20 +0000 (+0200) Subject: [#4141] handle EOF on readReady for kqueue X-Git-Tag: Kea-3.1.4~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3e17d8e5160492ab1ad010effb6a7eed828af5f;p=thirdparty%2Fkea.git [#4141] handle EOF on readReady for kqueue --- diff --git a/src/lib/util/kqueue_event_handler.cc b/src/lib/util/kqueue_event_handler.cc index 8ede3492f8..80a196118f 100644 --- a/src/lib/util/kqueue_event_handler.cc +++ b/src/lib/util/kqueue_event_handler.cc @@ -105,7 +105,7 @@ int KQueueEventHandler::waitEvent(uint32_t timeout_sec, uint32_t timeout_usec /* bool KQueueEventHandler::readReady(int fd) { auto range = map_.equal_range(fd); for (auto it = range.first; it != range.second; ++it) { - if (it->second->filter == EVFILT_READ) { + if ((it->second->flags & EV_EOF) || (it->second->filter == EVFILT_READ)) { return (true); } } @@ -118,7 +118,7 @@ bool KQueueEventHandler::hasError(int fd) { } auto range = map_.equal_range(fd); for (auto it = range.first; it != range.second; ++it) { - if ((it->second->flags & EV_EOF) || (it->second->filter == EV_ERROR)) { + if (it->second->filter == EV_ERROR) { return (true); } } diff --git a/src/lib/util/tests/fd_event_handler_unittests.h b/src/lib/util/tests/fd_event_handler_unittests.h index 047846e1f3..9de3d59ad5 100644 --- a/src/lib/util/tests/fd_event_handler_unittests.h +++ b/src/lib/util/tests/fd_event_handler_unittests.h @@ -213,11 +213,7 @@ TEST_F(FDEventHandlerTest, badFD) { EXPECT_EQ(0, errno); EXPECT_TRUE(handler_->readReady(pipe_fd_[0])); - if (handler_->type() == FDEventHandler::TYPE_KQUEUE) { - EXPECT_TRUE(handler_->hasError(pipe_fd_[0])); - } else { - EXPECT_FALSE(handler_->hasError(pipe_fd_[0])); - } + EXPECT_FALSE(handler_->hasError(pipe_fd_[0])); tr.join(); @@ -374,13 +370,6 @@ TEST_F(FDEventHandlerTest, badFD) { EXPECT_FALSE(handler_->readReady(pipe_fd_[1])); EXPECT_TRUE(handler_->hasError(pipe_fd_[1])); - } else if (handler_->type() == FDEventHandler::TYPE_KQUEUE) { - EXPECT_EQ(1, handler_->waitEvent(1, 0)); - - EXPECT_EQ(0, errno); - - EXPECT_TRUE(handler_->readReady(pipe_fd_[1])); - EXPECT_TRUE(handler_->hasError(pipe_fd_[1])); } else { EXPECT_EQ(1, handler_->waitEvent(1, 0)); @@ -402,11 +391,7 @@ TEST_F(FDEventHandlerTest, hup) { close(pipe_fd_[1]); EXPECT_EQ(1, handler_->waitEvent(0, 1000)); EXPECT_TRUE(handler_->readReady(pipe_fd_[0])); - if (handler_->type() == FDEventHandler::TYPE_KQUEUE) { - EXPECT_TRUE(handler_->hasError(pipe_fd_[0])); - } else { - EXPECT_FALSE(handler_->hasError(pipe_fd_[0])); - } + EXPECT_FALSE(handler_->hasError(pipe_fd_[0])); close(pipe_fd_[0]); pipe(pipe_fd_);