Skip to content

Commit b3b3e4a

Browse files
authored
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.
1 parent 771f34a commit b3b3e4a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

shard_connection.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ verify_request::~verify_request(void)
129129
shard_connection::shard_connection(unsigned int id, connections_manager* conns_man, benchmark_config* config,
130130
struct event_base* event_base, abstract_protocol* abs_protocol) :
131131
m_address(NULL), m_port(NULL), m_unix_sockaddr(NULL),
132-
m_bev(NULL), m_request_per_cur_interval(0), m_pending_resp(0), m_connection_state(conn_disconnected),
132+
m_bev(NULL), m_event_timer(NULL), m_request_per_cur_interval(0), m_pending_resp(0), m_connection_state(conn_disconnected),
133133
m_hello(setup_done), m_authentication(setup_done), m_db_selection(setup_done), m_cluster_slots(setup_done) {
134134
m_id = id;
135135
m_conns_manager = conns_man;
@@ -174,6 +174,11 @@ shard_connection::~shard_connection() {
174174
m_bev = NULL;
175175
}
176176

177+
if (m_event_timer != NULL) {
178+
event_free(m_event_timer);
179+
m_event_timer = NULL;
180+
}
181+
177182
if (m_protocol != NULL) {
178183
delete m_protocol;
179184
m_protocol = NULL;
@@ -298,8 +303,13 @@ int shard_connection::connect(struct connect_info* addr) {
298303
void shard_connection::disconnect() {
299304
if (m_bev) {
300305
bufferevent_free(m_bev);
306+
m_bev = NULL;
307+
}
308+
309+
if (m_event_timer != NULL) {
310+
event_free(m_event_timer);
311+
m_event_timer = NULL;
301312
}
302-
m_bev = NULL;
303313

304314
// empty pipeline
305315
while (m_pending_resp)

0 commit comments

Comments
 (0)