Reset persistent MySQL connections

When a persistent connection is taken from the pool, the state is reset
with a COM_CHANGE_USER on the next write. This allows reuse of persistent
connections without having to worry about the state of the MySQL session.
This commit is contained in:
Markus Makela
2016-10-28 11:57:52 +03:00
parent e8e2933b56
commit 5085b41d20
5 changed files with 102 additions and 20 deletions

View File

@ -102,6 +102,7 @@ MySQLProtocol* mysql_protocol_init(DCB* dcb, int fd)
p->protocol_command.scom_cmd = MYSQL_COM_UNDEFINED;
p->protocol_command.scom_nresponse_packets = 0;
p->protocol_command.scom_nbytes_to_read = 0;
p->stored_query = NULL;
#if defined(SS_DEBUG)
p->protocol_chk_top = CHK_NUM_PROTOCOL;
p->protocol_chk_tail = CHK_NUM_PROTOCOL;
@ -145,6 +146,9 @@ void mysql_protocol_done(DCB* dcb)
MXS_FREE(scmd);
scmd = scmd2;
}
gwbuf_free(p->stored_query);
p->protocol_state = MYSQL_PROTOCOL_DONE;
retblock: