diff --git a/doc/configuration.txt b/doc/configuration.txt index a8ba58a90..e434a4750 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -7745,14 +7745,15 @@ no option logasap logging. -option mysql-check [ user [ post-41 ] ] +option mysql-check [ user [ { post-41 | pre-41 } ] ] Use MySQL health checks for server testing May be used in sections : defaults | frontend | listen | backend yes | no | yes | yes Arguments : This is the username which will be used when connecting to MySQL server. - post-41 Send post v4.1 client compatible checks + post-41 Send post v4.1 client compatible checks (the default) + pre-41 Send pre v4.1 client compatible checks If you specify a username, the check consists of sending two MySQL packet, one Client Authentication packet, and one QUIT packet, to correctly close diff --git a/reg-tests/checks/mysql-check.vtc b/reg-tests/checks/mysql-check.vtc index 061f2c1bb..5344d95fc 100644 --- a/reg-tests/checks/mysql-check.vtc +++ b/reg-tests/checks/mysql-check.vtc @@ -89,13 +89,13 @@ haproxy h1 -conf { backend be2 log ${S2_addr}:${S2_port} daemon option log-health-checks - option mysql-check user user + option mysql-check user user pre-41 server srv ${h1_mysql1_addr}:${h1_mysql1_port} check inter 1s rise 1 fall 1 backend be3 log ${S3_addr}:${S3_port} daemon option log-health-checks - option mysql-check user user post-41 + option mysql-check user user server srv ${h1_mysql2_addr}:${h1_mysql2_port} check inter 1s rise 1 fall 1 backend be4 diff --git a/src/checks.c b/src/checks.c index d22c11310..74b0fc85f 100644 --- a/src/checks.c +++ b/src/checks.c @@ -6852,21 +6852,21 @@ int proxy_parse_mysql_check_opt(char **args, int cur_arg, struct proxy *curpx, s goto error; } - if (*args[cur_arg+2]) { - if (strcmp(args[cur_arg+2], "post-41") != 0) { - ha_alert("parsing [%s:%d] : keyword '%s' only supports option 'post-41' (got '%s').\n", - file, line, args[cur_arg], args[cur_arg+2]); - goto error; - } + if (!*args[cur_arg+2] || strcmp(args[cur_arg+2], "post-41") == 0) { packetlen = userlen + 7 + 27; mysql_req = mysql41_req; mysql_rsname = mysql41_rsname; } - else { + else if (strcmp(args[cur_arg+2], "pre-41") == 0) { packetlen = userlen + 7; mysql_req = mysql40_req; mysql_rsname = mysql40_rsname; } + else { + ha_alert("parsing [%s:%d] : keyword '%s' only supports 'post-41' and 'pre-41' (got '%s').\n", + file, line, args[cur_arg], args[cur_arg+2]); + goto error; + } hdr[0] = (unsigned char)(packetlen & 0xff); hdr[1] = (unsigned char)((packetlen >> 8) & 0xff);