Skip to content

Commit 289d8bb

Browse files
authored
Merge pull request #3648 from sysown/v2.3.2_3646_3647
Port to v2.3.2 of PRs #3646 and #3647
2 parents 38b8ebe + 7cbe4ce commit 289d8bb

File tree

7 files changed

+1135
-788
lines changed

7 files changed

+1135
-788
lines changed

lib/MySQL_Thread.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2543,7 +2543,10 @@ void MySQL_Threads_Handler::update_client_host_cache(struct sockaddr* client_soc
25432543
if (error) {
25442544
pthread_mutex_lock(&mutex_client_host_cache);
25452545
// If the cache is full, find the oldest entry on it, and update/remove it.
2546-
if (client_host_cache.size() >= static_cast<size_t>(mysql_thread___client_host_cache_size)) {
2546+
if (
2547+
mysql_thread___client_host_cache_size &&
2548+
client_host_cache.size() >= static_cast<size_t>(mysql_thread___client_host_cache_size)
2549+
) {
25472550
auto older_elem = std::min_element(
25482551
client_host_cache.begin(),
25492552
client_host_cache.end(),
@@ -2553,8 +2556,10 @@ void MySQL_Threads_Handler::update_client_host_cache(struct sockaddr* client_soc
25532556
return f_entry.second.updated_at < s_entry.second.updated_at;
25542557
}
25552558
);
2556-
if (older_elem->first != client_addr) {
2557-
client_host_cache.erase(older_elem);
2559+
if (older_elem != client_host_cache.end()) {
2560+
if (older_elem->first != client_addr) {
2561+
client_host_cache.erase(older_elem);
2562+
}
25582563
}
25592564
}
25602565

@@ -3711,7 +3716,9 @@ void MySQL_Thread::process_all_sessions() {
37113716
if (sess_time/1000 > (unsigned long long)mysql_thread___connect_timeout_client) {
37123717
proxy_warning("Closing not established client connection %s:%d after %llums\n",sess->client_myds->addr.addr,sess->client_myds->addr.port, sess_time/1000);
37133718
sess->healthy = 0;
3714-
GloMTH->update_client_host_cache(sess->client_myds->client_addr, true);
3719+
if (mysql_thread___client_host_cache_size) {
3720+
GloMTH->update_client_host_cache(sess->client_myds->client_addr, true);
3721+
}
37153722
}
37163723
}
37173724
if (maintenance_loop) {

lib/mysql_connection.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2293,17 +2293,18 @@ bool MySQL_Connection::IsKeepMultiplexEnabledVariables(char *query_digest_text)
22932293
}
22942294
//filter @@session. and @@
22952295
char *match=NULL;
2296+
char* last_pos=NULL;
2297+
const int at_session_offset = strlen("@@session.");
2298+
const int double_at_offset = strlen("@@");
22962299
while (query_digest_text_filter_select && (match = strcasestr(query_digest_text_filter_select,"@@session."))) {
2297-
*match = '\0';
2298-
strcat(query_digest_text_filter_select, match+strlen("@@session."));
2300+
memmove(match, match + at_session_offset, strlen(match) - at_session_offset);
2301+
last_pos = match + strlen(match) - at_session_offset;
2302+
*last_pos = '\0';
22992303
}
23002304
while (query_digest_text_filter_select && (match = strcasestr(query_digest_text_filter_select,"@@"))) {
2301-
*match = '\0';
2302-
if (strlen(query_digest_text_filter_select) == 0) {
2303-
memcpy(query_digest_text_filter_select, match, strlen("@@"));
2304-
} else {
2305-
strcat(query_digest_text_filter_select, match+strlen("@@"));
2306-
}
2305+
memmove(match, match + double_at_offset, strlen(match) - double_at_offset);
2306+
last_pos = match + strlen(match) - double_at_offset;
2307+
*last_pos = '\0';
23072308
}
23082309

23092310
std::vector<char*>query_digest_text_filter_select_v;

test/tap/tests/client_host_err/create_netns_n.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/bin/bash
2+
3+
# NOTE: This script is currently unused, but it's left here because it's useful
4+
# for creating network namespaces in a easy way. It could be of use for future
5+
# testing.
6+
27
if [[ $EUID -ne 0 ]]; then
38
echo "This script must be run as root"
49
exit 1

test/tap/tests/client_host_err/delete_netns_n.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/bin/bash
2+
3+
# NOTE: This script is currently unused, but it's left here because it's useful
4+
# for deleting network namespaces in a easy way. It could be of use for future
5+
# testing.
6+
27
if [[ $EUID -ne 0 ]]; then
38
echo "This script must be run as root"
49
exit 1

0 commit comments

Comments
 (0)