Fix some issues with transferring conn back to server

This commit is contained in:
2025-08-22 10:51:24 -04:00
parent 1d86f48d5e
commit ba3258ab16
4 changed files with 33 additions and 22 deletions

View File

@@ -323,7 +323,8 @@ private:
* @param server Weak reference to the server for safe cleanup
*/
Connection(struct sockaddr_storage addr, int fd, int64_t id,
ConnectionHandler *handler, std::weak_ptr<Server> server);
size_t epoll_index, ConnectionHandler *handler,
std::weak_ptr<Server> server);
/**
* @brief Server-only factory method for creating connections.
@@ -345,7 +346,8 @@ private:
*/
static std::unique_ptr<Connection>
createForServer(struct sockaddr_storage addr, int fd, int64_t id,
ConnectionHandler *handler, std::weak_ptr<Server> server);
size_t epoll_index, ConnectionHandler *handler,
std::weak_ptr<Server> server);
// Networking interface - only accessible by Server
int readBytes(char *buf, size_t buffer_size);
@@ -357,8 +359,10 @@ private:
int getFd() const { return fd_; }
bool hasMessages() const { return !messages_.empty(); }
bool shouldClose() const { return closeConnection_; }
size_t getEpollIndex() const { return epoll_index_; }
const int fd_;
const int64_t id_;
const size_t epoll_index_; // Index of the epoll instance this connection uses
struct sockaddr_storage addr_; // sockaddr_storage handles IPv4/IPv6
ArenaAllocator arena_;
ConnectionHandler *handler_;