From 6a365146a4dbe35447701c9d4982cf200ebab05e Mon Sep 17 00:00:00 2001 From: Craig Edwards Date: Tue, 19 Nov 2024 21:15:41 +0000 Subject: [PATCH] dont resize the ke_list --- src/dpp/socketengines/kqueue.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/dpp/socketengines/kqueue.cpp b/src/dpp/socketengines/kqueue.cpp index 0f162d3fc1..d15b2574f5 100644 --- a/src/dpp/socketengines/kqueue.cpp +++ b/src/dpp/socketengines/kqueue.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,7 @@ namespace dpp { struct socket_engine_kqueue : public socket_engine_base { int kqueue_handle{INVALID_SOCKET}; - std::vector ke_list; + std::array ke_list; socket_engine_kqueue(const socket_engine_kqueue&) = delete; socket_engine_kqueue(socket_engine_kqueue&&) = delete; @@ -41,7 +42,6 @@ struct socket_engine_kqueue : public socket_engine_base { socket_engine_kqueue& operator=(socket_engine_kqueue&&) = delete; explicit socket_engine_kqueue(cluster* creator) : socket_engine_base(creator), kqueue_handle(kqueue()) { - ke_list.resize(16); if (kqueue_handle == -1) { throw dpp::connection_exception("Failed to initialise kqueue()"); } @@ -57,7 +57,7 @@ struct socket_engine_kqueue : public socket_engine_base { struct timespec ts{}; ts.tv_sec = 1; - int i = kevent(kqueue_handle, NULL, 0, &ke_list.front(), static_cast(ke_list.size()), &ts); + int i = kevent(kqueue_handle, NULL, 0, ke_list.data(), static_cast(ke_list.size()), &ts); if (i < 0) { return; } @@ -111,9 +111,6 @@ struct socket_engine_kqueue : public socket_engine_base { EV_SET(&ke, e.fd, EVFILT_WRITE, EV_ADD | EV_ONESHOT, 0, 0, static_cast(se)); kevent(kqueue_handle, &ke, 1, 0, 0, nullptr); } - if (fds.size() * 3 > ke_list.size()) { - ke_list.resize(fds.size() * 3); - } } return r; } @@ -131,9 +128,6 @@ struct socket_engine_kqueue : public socket_engine_base { EV_SET(&ke, e.fd, EVFILT_WRITE, EV_ADD | EV_ONESHOT, 0, 0, static_cast(se)); kevent(kqueue_handle, &ke, 1, 0, 0, nullptr); } - if (fds.size() * 3 > ke_list.size()) { - ke_list.resize(fds.size() * 3); - } } return r; }