Allow multiple epoll instances on server
This commit is contained in:
@@ -103,11 +103,14 @@ private:
|
||||
std::vector<std::thread> threads_;
|
||||
std::atomic<int64_t> connection_id_{0};
|
||||
|
||||
// Round-robin counter for connection distribution
|
||||
std::atomic<size_t> connection_distribution_counter_{0};
|
||||
|
||||
// Shutdown coordination
|
||||
int shutdown_pipe_[2] = {-1, -1};
|
||||
|
||||
// Epoll file descriptor
|
||||
int epollfd_ = -1;
|
||||
// Multiple epoll file descriptors to reduce contention
|
||||
std::vector<int> epoll_fds_;
|
||||
int listen_sockfd_ = -1;
|
||||
|
||||
// Unique tags for special events to avoid type confusion in epoll data union
|
||||
@@ -118,14 +121,19 @@ private:
|
||||
void setup_shutdown_pipe();
|
||||
void setup_signal_handling();
|
||||
int create_listen_socket();
|
||||
void create_epoll_instances();
|
||||
void start_io_threads();
|
||||
void cleanup_resources();
|
||||
|
||||
// Helper to get epoll fd for a thread using round-robin
|
||||
int get_epoll_for_thread(int thread_id) const;
|
||||
|
||||
// Helper for processing connection I/O
|
||||
void process_connection_io(std::unique_ptr<Connection> &conn, int events);
|
||||
|
||||
// Helper for processing a batch of connections with their events
|
||||
void process_connection_batch(std::span<std::unique_ptr<Connection>> batch,
|
||||
void process_connection_batch(int epollfd,
|
||||
std::span<std::unique_ptr<Connection>> batch,
|
||||
std::span<const int> events, bool is_new);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user