Fix to MXS-80: https://mariadb.atlassian.net/browse/MXS-80
Fixed a possible null pointer dereference and schemarouter client sessions not being closed properly when connecting with an empty database.
This commit is contained in:
@ -608,21 +608,30 @@ SESSION *ptr;
|
||||
ptr = allSessions;
|
||||
while (ptr)
|
||||
{
|
||||
double idle = (hkheartbeat - ptr->client->last_read);
|
||||
idle = idle > 0 ? idle/10.0:0;
|
||||
|
||||
dcb_printf(dcb, "Session %d (%p)\n",ptr->ses_id, ptr);
|
||||
dcb_printf(dcb, "\tState: %s\n", session_state(ptr->state));
|
||||
dcb_printf(dcb, "\tService: %s (%p)\n", ptr->service->name, ptr->service);
|
||||
dcb_printf(dcb, "\tClient DCB: %p\n", ptr->client);
|
||||
|
||||
if (ptr->client && ptr->client->remote)
|
||||
{
|
||||
dcb_printf(dcb, "\tClient Address: %s%s%s\n",
|
||||
ptr->client->user?ptr->client->user:"",
|
||||
ptr->client->user?"@":"",
|
||||
ptr->client->remote);
|
||||
}
|
||||
|
||||
dcb_printf(dcb, "\tConnected: %s",
|
||||
asctime_r(localtime_r(&ptr->stats.connect, &result), timebuf));
|
||||
if(ptr->client->state == DCB_STATE_POLLING)
|
||||
dcb_printf(dcb, "\tIdle: %.0f seconds\n",idle);
|
||||
|
||||
if(ptr->client && ptr->client->state == DCB_STATE_POLLING)
|
||||
{
|
||||
double idle = (hkheartbeat - ptr->client->last_read);
|
||||
idle = idle > 0 ? idle/10.0:0;
|
||||
dcb_printf(dcb, "\tIdle: %.0f seconds\n",idle);
|
||||
}
|
||||
|
||||
ptr = ptr->next;
|
||||
}
|
||||
spinlock_release(&session_spin);
|
||||
|
||||
@ -1011,7 +1011,7 @@ static void closeSession(
|
||||
backend_ref_t* backend_ref;
|
||||
|
||||
LOGIF(LD, (skygw_log_write(LOGFILE_DEBUG,
|
||||
"%lu [RWSplit:closeSession]",
|
||||
"%lu [schemarouter:closeSession]",
|
||||
pthread_self())));
|
||||
|
||||
/**
|
||||
@ -2336,15 +2336,20 @@ static void clientReply (
|
||||
if((target = hashtable_fetch(router_cli_ses->dbhash,
|
||||
router_cli_ses->connect_db)) == NULL)
|
||||
{
|
||||
/** Unknown database, hang up on the client*/
|
||||
skygw_log_write_flush(LOGFILE_TRACE,"schemarouter: Connecting to a non-existent database '%s'",
|
||||
router_cli_ses->connect_db);
|
||||
router_cli_ses->rses_closed = true;
|
||||
char errmsg[128 + MYSQL_DATABASE_MAXLEN+1];
|
||||
sprintf(errmsg,"Unknown database '%s'",router_cli_ses->connect_db);
|
||||
GWBUF* errbuff = modutil_create_mysql_err_msg(1,0,1049,"42000",errmsg);
|
||||
router_cli_ses->rses_client_dcb->func.write(router_cli_ses->rses_client_dcb,errbuff);
|
||||
if(router_cli_ses->queue)
|
||||
{
|
||||
while((router_cli_ses->queue = gwbuf_consume(
|
||||
router_cli_ses->queue,gwbuf_length(router_cli_ses->queue))));
|
||||
}
|
||||
rses_end_locked_router_action(router_cli_ses);
|
||||
router_cli_ses->rses_client_dcb->func.hangup(router_cli_ses->rses_client_dcb);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user