Hi again Hervé,
Le Mercredi 13 Janvier 2010 12:56:30, Hervé COMMOWICK a écrit :
> Hi Cyril,
>
> I know the check is not perfect, because it doesn't handle a correct
> disconnection.
> Mysql expect the client to talk, and i think it's weird... in the
> future, i think it will be better to do a *real* mysql ping, but at the
> moment, the checks API doesn't let me handle this in a cleaner way.
This is not a patch but a start of reflection :
In the function event_srv_chk_r(int fd),
after this condition :
if (trash[4] != -1) {
I added this quick and dirty reply :
char handshake[] =
"\x22\x00\x00" /* packet length */
"\x01" /* packet number */
"\x00\x00" /* client capabilities */
"\x00\x00" /* extended client capabilities */
"\x00\x00\x00\x01" /* max packet */
"\x08" /* charset */
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
/* reserved (23 bytes) */
"\x00" /* username (null terminated string) */
"\x00"; /* empty password */
send(fd, handshake, sizeof(handshake), MSG_DONTWAIT | MSG_NOSIGNAL);
After several tests, this finishes the handshake correctly.
Note that this packet is only valid for mysql >= 4.1 (haproxy would have to
check the version to decide which reply to send).
At the moment, I have no mysql 4.0 to validate the other reply type.
For more information :
http://forge.mysql.com/wiki/MySQL_Internals_ClientServer_Protocol#Client_Authentication_Packet
I hope this will be helpful.
--
Cyril Bonté