Fixed client session termination due to wrong packet sequence numbers.

This commit is contained in:
Markus Makela
2014-12-16 14:33:05 +02:00
parent ef94b7ee54
commit e4042019e1

View File

@ -1877,6 +1877,7 @@ static int routeQuery(
route_target_t route_target = TARGET_UNDEFINED; route_target_t route_target = TARGET_UNDEFINED;
bool succp = false; bool succp = false;
char* tname = NULL; char* tname = NULL;
int i;
CHK_CLIENT_RSES(router_cli_ses); CHK_CLIENT_RSES(router_cli_ses);
@ -2064,7 +2065,6 @@ static int routeQuery(
*/ */
backend_ref_t* backend = NULL; backend_ref_t* backend = NULL;
DCB* backend_dcb = NULL; DCB* backend_dcb = NULL;
int i;
update_dbnames_hash(inst,inst->servers,inst->dbnames_hash); update_dbnames_hash(inst,inst->servers,inst->dbnames_hash);
@ -2157,6 +2157,7 @@ static int routeQuery(
tname = get_shard_target_name(inst,router_cli_ses,querybuf,qtype); tname = get_shard_target_name(inst,router_cli_ses,querybuf,qtype);
if( (tname == NULL && if( (tname == NULL &&
packet_type != MYSQL_COM_INIT_DB &&
router_cli_ses->rses_mysql_session->db[0] == '\0') || router_cli_ses->rses_mysql_session->db[0] == '\0') ||
(packet_type == MYSQL_COM_INIT_DB && change_successful) || (packet_type == MYSQL_COM_INIT_DB && change_successful) ||
packet_type == MYSQL_COM_FIELD_LIST || packet_type == MYSQL_COM_FIELD_LIST ||
@ -2172,18 +2173,23 @@ static int routeQuery(
} }
else else
{ {
if(!change_successful)
{
/** /**
* Bad shard status * Bad shard status. The changing of the database
* was not successful and the error message was already sent.
*/ */
sprintf(errstr,"Unknown database '%s'", ret = 1;
router_cli_ses->rses_mysql_session->db); }
errbuff = modutil_create_mysql_err_msg(1,0,1049, else
"42000", {
errstr); /** Something else went wrong, terminate connection */
gwbuf_free(querybuf); ret = 0;
return router_cli_ses->rses_client_dcb->func.write(router_cli_ses->rses_client_dcb,errbuff); }
goto retblock;
} }
} }
@ -4581,7 +4587,7 @@ static bool change_current_db(
reply_error: reply_error:
{ {
GWBUF* errbuf; GWBUF* errbuf;
errbuf = modutil_create_mysql_err_msg(2, 0, 1049, "42000", fail_str); errbuf = modutil_create_mysql_err_msg(1, 0, 1049, "42000", fail_str);
free(fail_str); free(fail_str);
if (errbuf == NULL) if (errbuf == NULL)