Skip to content

Commit

Permalink
Issue #285, Fix rate-limiting with cluster-mode (#286)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
YaacovHazan authored Jan 5, 2025
1 parent 771f34a commit b3b3e4a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions shard_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b3b3e4a

Please sign in to comment.