提交 6fec7de2 编写于 作者: H hjxilinx

fix bug #657. RPC module frees the msg body while other threads still access...

fix bug #657. RPC module frees the msg body while other threads still access that struct to cause the SIGSEGV error.
上级 9c468129
...@@ -1108,6 +1108,7 @@ int taosSendMsgToPeerH(void *thandle, char *pCont, int contLen, void *ahandle) { ...@@ -1108,6 +1108,7 @@ int taosSendMsgToPeerH(void *thandle, char *pCont, int contLen, void *ahandle) {
SRpcConn * pConn = (SRpcConn *)thandle; SRpcConn * pConn = (SRpcConn *)thandle;
STaosRpc * pServer; STaosRpc * pServer;
SRpcChann * pChann; SRpcChann * pChann;
uint8_t msgType;
if (pConn == NULL) return -1; if (pConn == NULL) return -1;
if (pConn->signature != pConn) return -1; if (pConn->signature != pConn) return -1;
...@@ -1133,8 +1134,9 @@ int taosSendMsgToPeerH(void *thandle, char *pCont, int contLen, void *ahandle) { ...@@ -1133,8 +1134,9 @@ int taosSendMsgToPeerH(void *thandle, char *pCont, int contLen, void *ahandle) {
} }
pthread_mutex_lock(&pChann->mutex); pthread_mutex_lock(&pChann->mutex);
msgType = pHeader->msgType;
if ((pHeader->msgType & 1) == 0) { if ((msgType & 1) == 0) {
// response // response
pConn->inType = 0; pConn->inType = 0;
tfree(pConn->pRspMsg); tfree(pConn->pRspMsg);
...@@ -1160,7 +1162,7 @@ int taosSendMsgToPeerH(void *thandle, char *pCont, int contLen, void *ahandle) { ...@@ -1160,7 +1162,7 @@ int taosSendMsgToPeerH(void *thandle, char *pCont, int contLen, void *ahandle) {
} }
tTrace("%s cid:%d sid:%d id:%s, msg:%s is put into queue pConn:%p", pServer->label, pConn->chann, pConn->sid, tTrace("%s cid:%d sid:%d id:%s, msg:%s is put into queue pConn:%p", pServer->label, pConn->chann, pConn->sid,
pConn->meterId, taosMsg[pHeader->msgType], pConn); pConn->meterId, taosMsg[msgType], pConn);
msgLen = 0; msgLen = 0;
} else { } else {
...@@ -1170,7 +1172,7 @@ int taosSendMsgToPeerH(void *thandle, char *pCont, int contLen, void *ahandle) { ...@@ -1170,7 +1172,7 @@ int taosSendMsgToPeerH(void *thandle, char *pCont, int contLen, void *ahandle) {
pServer->label, pConn->chann, pConn->sid, pConn->meterId, pConn); pServer->label, pConn->chann, pConn->sid, pConn->meterId, pConn);
} }
pConn->outType = pHeader->msgType; pConn->outType = msgType;
pConn->outTranId = pHeader->tranId; pConn->outTranId = pHeader->tranId;
pConn->pMsgNode = pMsgNode; pConn->pMsgNode = pMsgNode;
pConn->rspReceived = 0; pConn->rspReceived = 0;
...@@ -1182,7 +1184,7 @@ int taosSendMsgToPeerH(void *thandle, char *pCont, int contLen, void *ahandle) { ...@@ -1182,7 +1184,7 @@ int taosSendMsgToPeerH(void *thandle, char *pCont, int contLen, void *ahandle) {
if (msgLen) { if (msgLen) {
taosSendDataToPeer(pConn, (char *)pHeader, msgLen); taosSendDataToPeer(pConn, (char *)pHeader, msgLen);
if (pHeader->msgType & 1) { if (msgType & 1U) {
taosTmrReset(taosProcessTaosTimer, tsRpcTimer, pConn, pChann->tmrCtrl, &pConn->pTimer); taosTmrReset(taosProcessTaosTimer, tsRpcTimer, pConn, pChann->tmrCtrl, &pConn->pTimer);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册