From 857e501ca3ca13fa6ecc729b0b7d1deed9be9d34 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Thu, 24 Apr 2025 19:39:42 +0500 Subject: [PATCH] Added update_fd_at_index method --- include/ProxySQL_Poll.h | 1 + lib/ProxySQL_Poll.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/ProxySQL_Poll.h b/include/ProxySQL_Poll.h index 406c0e993..8dbcfc921 100644 --- a/include/ProxySQL_Poll.h +++ b/include/ProxySQL_Poll.h @@ -44,6 +44,7 @@ class ProxySQL_Poll { ProxySQL_Poll(); ~ProxySQL_Poll(); void add(uint32_t _events, int _fd, T *_myds, unsigned long long sent_time); + void update_fd_at_index(unsigned int idx, int _fd); void remove_index_fast(unsigned int i); int find_index(int fd); }; diff --git a/lib/ProxySQL_Poll.cpp b/lib/ProxySQL_Poll.cpp index 425bca51d..637a28879 100644 --- a/lib/ProxySQL_Poll.cpp +++ b/lib/ProxySQL_Poll.cpp @@ -126,6 +126,21 @@ void ProxySQL_Poll::add(uint32_t _events, int _fd, T *_myds, unsigned long lo len++; } +/** + * @brief Updates the file descriptor (FD) at a specific index in the ProxySQL_Poll object. + * + * This function updates the file descriptor (FD) at a specific index in the ProxySQL_Poll object. + * It does not modify any other associated data or metadata. + * + * @param idx The index of the file descriptor (FD) to update. + * @param _fd The new file descriptor (FD) value. + */ +template +void ProxySQL_Poll::update_fd_at_index(unsigned int idx, int _fd) { + if ((int)idx == -1 || idx >= len) return; + fds[idx].fd = _fd; +} + /** * @brief Removes a file descriptor (FD) and its associated MySQL_Data_Stream from the ProxySQL_Poll object. *