Fixed a memory leak in schemarouter.

This commit is contained in:
Markus Makela 2015-03-30 14:24:17 +03:00
parent 875e49c074
commit 5f422a96fc

View File

@ -402,7 +402,7 @@ int gen_databaselist(ROUTER_INSTANCE* inst, ROUTER_CLIENT_SES* session)
rval);
}
}
gwbuf_free(buffer);
return !rval;
}
@ -2223,6 +2223,7 @@ static void clientReply (
*/
if (!rses_begin_locked_router_action(router_cli_ses))
{
while((writebuf = gwbuf_consume(writebuf,gwbuf_length(writebuf))));
goto lock_failed;
}
/** Holding lock ensures that router session remains open */
@ -2252,6 +2253,7 @@ static void clientReply (
if (!rses_begin_locked_router_action(router_cli_ses))
{
/** Log to debug that router was closed */
while((writebuf = gwbuf_consume(writebuf,gwbuf_length(writebuf))));
goto lock_failed;
}
bref = get_bref_from_dcb(router_cli_ses, backend_dcb);
@ -2260,6 +2262,7 @@ static void clientReply (
{
/** Unlock router session */
rses_end_locked_router_action(router_cli_ses);
while((writebuf = gwbuf_consume(writebuf,gwbuf_length(writebuf))));
goto lock_failed;
}
@ -2307,7 +2310,7 @@ static void clientReply (
}
}
gwbuf_free(writebuf);
while((writebuf = gwbuf_consume(writebuf,gwbuf_length(writebuf))));
if(mapped)
{
@ -2330,7 +2333,10 @@ static void clientReply (
router_cli_ses->connect_db);
router_cli_ses->rses_closed = true;
if(router_cli_ses->queue)
gwbuf_free(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);
return;
}
@ -2384,7 +2390,7 @@ static void clientReply (
{
GWBUF* tmp = router_cli_ses->queue;
router_cli_ses->queue = router_cli_ses->queue->next;
tmp->next = NULL;
tmp->next = NULL;
char* querystr = modutil_get_SQL(tmp);
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Sending queued buffer for session %p: %s",
router_cli_ses->rses_client_dcb->session,
@ -2424,6 +2430,8 @@ static void clientReply (
strcpy(router_cli_ses->rses_mysql_session->db,router_cli_ses->connect_db);
ss_dassert(router_cli_ses->init == INIT_READY);
rses_end_locked_router_action(router_cli_ses);
if(writebuf)
while((writebuf = gwbuf_consume(writebuf,gwbuf_length(writebuf))));
return;
}