diff --git a/include/maxscale/protocol/mysql.h b/include/maxscale/protocol/mysql.h index 45cd92b52..72696ddc6 100644 --- a/include/maxscale/protocol/mysql.h +++ b/include/maxscale/protocol/mysql.h @@ -627,8 +627,10 @@ bool mxs_mysql_command_will_respond(uint8_t cmd); /* Type of the kill-command sent by client. */ typedef enum kill_type { - KT_CONNECTION, - KT_QUERY + KT_CONNECTION = (1 << 0), + KT_QUERY = (1 << 1), + KT_SOFT = (1 << 2), + KT_HARD = (1 << 3) } kill_type_t; void mxs_mysql_execute_kill(MXS_SESSION* issuer, uint64_t target_id, kill_type_t type); diff --git a/server/modules/protocol/MySQL/MySQLClient/mysql_client.cc b/server/modules/protocol/MySQL/MySQLClient/mysql_client.cc index 39c79381b..497369ff8 100644 --- a/server/modules/protocol/MySQL/MySQLClient/mysql_client.cc +++ b/server/modules/protocol/MySQL/MySQLClient/mysql_client.cc @@ -1762,7 +1762,7 @@ static bool parse_kill_query(char *query, uint64_t *thread_id_out, kill_type_t * const char WORD_SOFT[] = "SOFT"; const char DELIM[] = " \n\t"; - kill_type_t kill_type = KT_CONNECTION; + int kill_type = KT_CONNECTION; unsigned long long int thread_id = 0; enum kill_parse_state_t @@ -1806,10 +1806,14 @@ static bool parse_kill_query(char *query, uint64_t *thread_id_out, kill_type_t * get_next = true; } - if (strncasecmp(token, WORD_HARD, sizeof(WORD_HARD) - 1) == 0 || - strncasecmp(token, WORD_SOFT, sizeof(WORD_SOFT) - 1) == 0) + if (strncasecmp(token, WORD_HARD, sizeof(WORD_HARD) - 1) == 0) { - /* This is an optional token and needs to be ignored */ + kill_type |= KT_HARD; + get_next = true; + } + else if (strncasecmp(token, WORD_SOFT, sizeof(WORD_SOFT) - 1) == 0) + { + kill_type |= KT_SOFT; get_next = true; } else @@ -1888,7 +1892,7 @@ static bool parse_kill_query(char *query, uint64_t *thread_id_out, kill_type_t * else { *thread_id_out = thread_id; - *kt_out = kill_type; + *kt_out = (kill_type_t)kill_type; return true; } } diff --git a/server/modules/protocol/MySQL/mysql_common.cc b/server/modules/protocol/MySQL/mysql_common.cc index c6b314796..fb5e10821 100644 --- a/server/modules/protocol/MySQL/mysql_common.cc +++ b/server/modules/protocol/MySQL/mysql_common.cc @@ -1731,8 +1731,12 @@ void mxs_mysql_execute_kill(MXS_SESSION* issuer, uint64_t target_id, kill_type_t it != info.targets.end(); it++) { LocalClient* client = LocalClient::create(issuer, it->first); + const char* hard = (type & KT_HARD) ? "HARD " : + (type & KT_SOFT) ? "SOFT " : + ""; + const char* query = (type & KT_QUERY) ? "QUERY " : ""; std::stringstream ss; - ss << "KILL " << (type == KT_QUERY ? "QUERY " : "") << it->second; + ss << "KILL " << hard << query << it->second; GWBUF* buffer = modutil_create_query(ss.str().c_str()); client->queue_query(buffer); gwbuf_free(buffer);