Merge branch '3.0' into enh/opt-transport
This commit is contained in:
parent
bd69f73597
commit
ea7178d714
|
@ -461,7 +461,7 @@ void transPrintEpSet(SEpSet* pEpSet);
|
||||||
|
|
||||||
void transFreeMsg(void* msg);
|
void transFreeMsg(void* msg);
|
||||||
int32_t transCompressMsg(char* msg, int32_t len);
|
int32_t transCompressMsg(char* msg, int32_t len);
|
||||||
int32_t transDecompressMsg(char** msg, int32_t len);
|
int32_t transDecompressMsg(char** msg, int32_t* len);
|
||||||
|
|
||||||
int32_t transOpenRefMgt(int size, void (*func)(void*));
|
int32_t transOpenRefMgt(int size, void (*func)(void*));
|
||||||
void transCloseRefMgt(int32_t refMgt);
|
void transCloseRefMgt(int32_t refMgt);
|
||||||
|
|
|
@ -561,7 +561,7 @@ void cliHandleResp(SCliConn* conn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((code = transDecompressMsg((char**)&pHead, msgLen)) < 0) {
|
if ((code = transDecompressMsg((char**)&pHead, &msgLen)) < 0) {
|
||||||
tDebug("%s conn %p recv invalid packet, failed to decompress", CONN_GET_INST_LABEL(conn), conn);
|
tDebug("%s conn %p recv invalid packet, failed to decompress", CONN_GET_INST_LABEL(conn), conn);
|
||||||
// TODO: notify cb
|
// TODO: notify cb
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -59,7 +59,7 @@ int32_t transCompressMsg(char* msg, int32_t len) {
|
||||||
taosMemoryFree(buf);
|
taosMemoryFree(buf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
int32_t transDecompressMsg(char** msg, int32_t len) {
|
int32_t transDecompressMsg(char** msg, int32_t* len) {
|
||||||
STransMsgHead* pHead = (STransMsgHead*)(*msg);
|
STransMsgHead* pHead = (STransMsgHead*)(*msg);
|
||||||
if (pHead->comp == 0) return 0;
|
if (pHead->comp == 0) return 0;
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ int32_t transDecompressMsg(char** msg, int32_t len) {
|
||||||
STransCompMsg* pComp = (STransCompMsg*)pCont;
|
STransCompMsg* pComp = (STransCompMsg*)pCont;
|
||||||
int32_t oriLen = htonl(pComp->contLen);
|
int32_t oriLen = htonl(pComp->contLen);
|
||||||
|
|
||||||
|
int32_t tlen = *len;
|
||||||
char* buf = taosMemoryCalloc(1, oriLen + sizeof(STransMsgHead));
|
char* buf = taosMemoryCalloc(1, oriLen + sizeof(STransMsgHead));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -75,9 +76,10 @@ int32_t transDecompressMsg(char** msg, int32_t len) {
|
||||||
|
|
||||||
STransMsgHead* pNewHead = (STransMsgHead*)buf;
|
STransMsgHead* pNewHead = (STransMsgHead*)buf;
|
||||||
int32_t decompLen = LZ4_decompress_safe(pCont + sizeof(STransCompMsg), (char*)pNewHead->content,
|
int32_t decompLen = LZ4_decompress_safe(pCont + sizeof(STransCompMsg), (char*)pNewHead->content,
|
||||||
len - sizeof(STransMsgHead) - sizeof(STransCompMsg), oriLen);
|
tlen - sizeof(STransMsgHead) - sizeof(STransCompMsg), oriLen);
|
||||||
memcpy((char*)pNewHead, (char*)pHead, sizeof(STransMsgHead));
|
memcpy((char*)pNewHead, (char*)pHead, sizeof(STransMsgHead));
|
||||||
|
|
||||||
|
*len = oriLen + sizeof(STransMsgHead);
|
||||||
pNewHead->msgLen = htonl(oriLen + sizeof(STransMsgHead));
|
pNewHead->msgLen = htonl(oriLen + sizeof(STransMsgHead));
|
||||||
|
|
||||||
taosMemoryFree(pHead);
|
taosMemoryFree(pHead);
|
||||||
|
|
|
@ -510,6 +510,12 @@ static bool uvHandleReq(SSvrConn* pConn) {
|
||||||
tError("%s conn %p read invalid packet", transLabel(pInst), pConn);
|
tError("%s conn %p read invalid packet", transLabel(pInst), pConn);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (transDecompressMsg((char**)&pHead, &msgLen) < 0) {
|
||||||
|
tError("%s conn %p recv invalid packet, failed to decompress", transLabel(pInst), pConn);
|
||||||
|
taosMemoryFree(pHead);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (uvConnMayGetUserInfo(pConn, &pHead, &msgLen) == true) {
|
if (uvConnMayGetUserInfo(pConn, &pHead, &msgLen) == true) {
|
||||||
tDebug("%s conn %p get user info", transLabel(pInst), pConn);
|
tDebug("%s conn %p get user info", transLabel(pInst), pConn);
|
||||||
}
|
}
|
||||||
|
@ -518,11 +524,6 @@ static bool uvHandleReq(SSvrConn* pConn) {
|
||||||
tTrace("%s conn %p not reset read buf", transLabel(pInst), pConn);
|
tTrace("%s conn %p not reset read buf", transLabel(pInst), pConn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transDecompressMsg((char**)&pHead, msgLen) < 0) {
|
|
||||||
tError("%s conn %p recv invalid packet, failed to decompress", transLabel(pInst), pConn);
|
|
||||||
taosMemoryFree(pHead);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
pHead->code = htonl(pHead->code);
|
pHead->code = htonl(pHead->code);
|
||||||
pHead->msgLen = htonl(pHead->msgLen);
|
pHead->msgLen = htonl(pHead->msgLen);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue