Skip to content

Commit

Permalink
Minor code optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
renecannao committed Jan 25, 2024
1 parent 5703802 commit 78fd49e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/MySQL_Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ class MySQL_Session
* maintenance thread. These values will be used to release the retained connections in the specific
* hostgroups in housekeeping operations, before client packet processing. Currently 'housekeeping_before_pkts'.
*/
size_t hgs_expired_conns_cnt = 0;
std::vector<int32_t> hgs_expired_conns {};
char * default_schema;
char * user_attributes;
Expand Down
6 changes: 5 additions & 1 deletion lib/MySQL_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ void MySQL_Session::update_expired_conns(const vector<function<bool(MySQL_Connec
}
}
}
hgs_expired_conns_cnt = hgs_expired_conns.size();
}

MySQL_Backend * MySQL_Session::create_backend(int hostgroup_id, MySQL_Data_Stream *_myds) {
Expand Down Expand Up @@ -4837,6 +4838,7 @@ void MySQL_Session::housekeeping_before_pkts() {
if (hgs_expired_conns.empty() == false) {
hgs_expired_conns.clear();
}
hgs_expired_conns_cnt = hgs_expired_conns.size();
}
}

Expand Down Expand Up @@ -4884,7 +4886,9 @@ int MySQL_Session::handler() {
}
}

housekeeping_before_pkts();
if (unlikely(hgs_expired_conns_cnt != 0)) {
housekeeping_before_pkts();
}
handler_ret = get_pkts_from_client(wrong_pass, pkt);
if (handler_ret != 0) {
return handler_ret;
Expand Down

0 comments on commit 78fd49e

Please sign in to comment.