From b3b3e4a670f76f5a66d0729e5915f15f2c3f96b6 Mon Sep 17 00:00:00 2001 From: YaacovHazan <31382944+YaacovHazan@users.noreply.github.com> Date: Sun, 5 Jan 2025 21:27:16 +0200 Subject: [PATCH] Issue #285, Fix rate-limiting with cluster-mode (#286) When a connection disconnected, the timer event was not free, and cause the test to keep running forever. One of these cases is when we are starting the benchmark in cluster-mode and using the replica's ip/port. --- shard_connection.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/shard_connection.cpp b/shard_connection.cpp index 0c8a54b..e873308 100644 --- a/shard_connection.cpp +++ b/shard_connection.cpp @@ -129,7 +129,7 @@ verify_request::~verify_request(void) shard_connection::shard_connection(unsigned int id, connections_manager* conns_man, benchmark_config* config, struct event_base* event_base, abstract_protocol* abs_protocol) : m_address(NULL), m_port(NULL), m_unix_sockaddr(NULL), - m_bev(NULL), m_request_per_cur_interval(0), m_pending_resp(0), m_connection_state(conn_disconnected), + m_bev(NULL), m_event_timer(NULL), m_request_per_cur_interval(0), m_pending_resp(0), m_connection_state(conn_disconnected), m_hello(setup_done), m_authentication(setup_done), m_db_selection(setup_done), m_cluster_slots(setup_done) { m_id = id; m_conns_manager = conns_man; @@ -174,6 +174,11 @@ shard_connection::~shard_connection() { m_bev = NULL; } + if (m_event_timer != NULL) { + event_free(m_event_timer); + m_event_timer = NULL; + } + if (m_protocol != NULL) { delete m_protocol; m_protocol = NULL; @@ -298,8 +303,13 @@ int shard_connection::connect(struct connect_info* addr) { void shard_connection::disconnect() { if (m_bev) { bufferevent_free(m_bev); + m_bev = NULL; + } + + if (m_event_timer != NULL) { + event_free(m_event_timer); + m_event_timer = NULL; } - m_bev = NULL; // empty pipeline while (m_pending_resp)