Copy the protocol name and adjust the kill code in asyncprotocol
This commit is contained in:
@ -286,7 +286,6 @@ int AsyncProtocolAction(SConnection * pCon, SicsInterp * pSics,
|
|||||||
void defaultKillPrivate(pAsyncProtocol p)
|
void defaultKillPrivate(pAsyncProtocol p)
|
||||||
{
|
{
|
||||||
if (p->privateData) {
|
if (p->privateData) {
|
||||||
/* TODO: should we do anything? */
|
|
||||||
free(p->privateData);
|
free(p->privateData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,15 +294,22 @@ void AsyncProtocolKill(void *pData)
|
|||||||
{
|
{
|
||||||
pAsyncProtocol self = (pAsyncProtocol) pData;
|
pAsyncProtocol self = (pAsyncProtocol) pData;
|
||||||
int i;
|
int i;
|
||||||
if (self->pDes)
|
|
||||||
DeleteDescriptor(self->pDes);
|
|
||||||
if (self->sendTerminator != NULL)
|
|
||||||
free(self->sendTerminator);
|
|
||||||
for (i = 0; i < 10; ++i)
|
|
||||||
if (self->replyTerminator[i] != NULL)
|
|
||||||
free(self->replyTerminator[i]);
|
|
||||||
if (self->killPrivate)
|
if (self->killPrivate)
|
||||||
self->killPrivate(self);
|
self->killPrivate(self);
|
||||||
|
if (self->pDes)
|
||||||
|
DeleteDescriptor(self->pDes);
|
||||||
|
self->pDes = NULL;
|
||||||
|
if (self->protocolName)
|
||||||
|
free(self->protocolName);
|
||||||
|
self->protocolName = NULL;
|
||||||
|
if (self->sendTerminator != NULL)
|
||||||
|
free(self->sendTerminator);
|
||||||
|
self->sendTerminator = NULL;
|
||||||
|
for (i = 0; i < 10; ++i) {
|
||||||
|
if (self->replyTerminator[i] != NULL)
|
||||||
|
free(self->replyTerminator[i]);
|
||||||
|
self->replyTerminator[i] = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pAsyncProtocol AsyncProtocolCreate(SicsInterp * pSics,
|
pAsyncProtocol AsyncProtocolCreate(SicsInterp * pSics,
|
||||||
@ -338,6 +344,7 @@ pAsyncProtocol AsyncProtocolCreate(SicsInterp * pSics,
|
|||||||
AsyncProtocolKill(self);
|
AsyncProtocolKill(self);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
self->protocolName = strdup(protocolName);
|
||||||
self->sendCommand = defaultSendCommand;
|
self->sendCommand = defaultSendCommand;
|
||||||
self->handleInput = defaultHandleInput;
|
self->handleInput = defaultHandleInput;
|
||||||
self->handleEvent = defaultHandleEvent;
|
self->handleEvent = defaultHandleEvent;
|
||||||
|
@ -45,7 +45,7 @@ struct __async_txn {
|
|||||||
int inp_idx; /**< index of next character (number already received) */
|
int inp_idx; /**< index of next character (number already received) */
|
||||||
AsyncTxnHandler handleResponse; /**< Txn response handler of command sender */
|
AsyncTxnHandler handleResponse; /**< Txn response handler of command sender */
|
||||||
void *proto_private; /**< Protocol Private structure */
|
void *proto_private; /**< Protocol Private structure */
|
||||||
void (*kill_private) (struct __async_txn *pTxn); /**< if it needs killing */
|
void (*kill_private) (pAsyncTxn pTxn); /**< if it needs killing */
|
||||||
void *cntx; /**< opaque context used by command sender */
|
void *cntx; /**< opaque context used by command sender */
|
||||||
/* The cntx field may be used by protocol handler from sendCommand
|
/* The cntx field may be used by protocol handler from sendCommand
|
||||||
* as long as it is restored when response is complete
|
* as long as it is restored when response is complete
|
||||||
|
Reference in New Issue
Block a user