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); rval);
} }
} }
gwbuf_free(buffer);
return !rval; return !rval;
} }
@ -2223,6 +2223,7 @@ static void clientReply (
*/ */
if (!rses_begin_locked_router_action(router_cli_ses)) if (!rses_begin_locked_router_action(router_cli_ses))
{ {
while((writebuf = gwbuf_consume(writebuf,gwbuf_length(writebuf))));
goto lock_failed; goto lock_failed;
} }
/** Holding lock ensures that router session remains open */ /** Holding lock ensures that router session remains open */
@ -2252,6 +2253,7 @@ static void clientReply (
if (!rses_begin_locked_router_action(router_cli_ses)) if (!rses_begin_locked_router_action(router_cli_ses))
{ {
/** Log to debug that router was closed */ /** Log to debug that router was closed */
while((writebuf = gwbuf_consume(writebuf,gwbuf_length(writebuf))));
goto lock_failed; goto lock_failed;
} }
bref = get_bref_from_dcb(router_cli_ses, backend_dcb); bref = get_bref_from_dcb(router_cli_ses, backend_dcb);
@ -2260,6 +2262,7 @@ static void clientReply (
{ {
/** Unlock router session */ /** Unlock router session */
rses_end_locked_router_action(router_cli_ses); rses_end_locked_router_action(router_cli_ses);
while((writebuf = gwbuf_consume(writebuf,gwbuf_length(writebuf))));
goto lock_failed; goto lock_failed;
} }
@ -2307,7 +2310,7 @@ static void clientReply (
} }
} }
gwbuf_free(writebuf); while((writebuf = gwbuf_consume(writebuf,gwbuf_length(writebuf))));
if(mapped) if(mapped)
{ {
@ -2330,7 +2333,10 @@ static void clientReply (
router_cli_ses->connect_db); router_cli_ses->connect_db);
router_cli_ses->rses_closed = true; router_cli_ses->rses_closed = true;
if(router_cli_ses->queue) 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); rses_end_locked_router_action(router_cli_ses);
return; return;
} }
@ -2424,6 +2430,8 @@ static void clientReply (
strcpy(router_cli_ses->rses_mysql_session->db,router_cli_ses->connect_db); strcpy(router_cli_ses->rses_mysql_session->db,router_cli_ses->connect_db);
ss_dassert(router_cli_ses->init == INIT_READY); ss_dassert(router_cli_ses->init == INIT_READY);
rses_end_locked_router_action(router_cli_ses); rses_end_locked_router_action(router_cli_ses);
if(writebuf)
while((writebuf = gwbuf_consume(writebuf,gwbuf_length(writebuf))));
return; return;
} }