Restructure free_command to afford protocol module more control

This allows the protocol module first cleanup opportunity on Txn
This commit is contained in:
Douglas Clowes
2014-08-21 17:23:42 +10:00
parent 99dea317f0
commit 6054eeeae9

View File

@ -95,15 +95,24 @@ static const char *state_name(AsyncState the_state)
*/
static void free_command(pAQ_Cmd myCmd)
{
free(myCmd->tran->out_buf);
free(myCmd->tran->inp_buf);
if (myCmd->tran->proto_private)
if (myCmd->tran->kill_private)
myCmd->tran->kill_private(myCmd->tran);
else
free(myCmd->tran->proto_private);
free(myCmd->tran);
free(myCmd);
if (myCmd) {
pAsyncTxn myTxn = myCmd->tran;
if (myTxn) {
/*
* Allow kill_private to clean it all if it wants
*/
if (myTxn->kill_private)
myTxn->kill_private(myTxn);
if (myTxn->out_buf)
free(myTxn->out_buf);
if (myTxn->inp_buf)
free(myTxn->inp_buf);
if (myTxn->proto_private)
free(myTxn->proto_private);
free(myTxn);
}
free(myCmd);
}
}
/* ---------------------------- Local ------------------------------------