Merge branch '3.0' into enh/opt-transport

This commit is contained in:
yihaoDeng 2024-09-18 10:46:42 +08:00
parent bd69f73597
commit ea7178d714
4 changed files with 13 additions and 10 deletions

View File

@ -461,7 +461,7 @@ void transPrintEpSet(SEpSet* pEpSet);
void transFreeMsg(void* msg);
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*));
void transCloseRefMgt(int32_t refMgt);

View File

@ -561,7 +561,7 @@ void cliHandleResp(SCliConn* conn) {
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);
// TODO: notify cb
return;

View File

@ -59,7 +59,7 @@ int32_t transCompressMsg(char* msg, int32_t len) {
taosMemoryFree(buf);
return ret;
}
int32_t transDecompressMsg(char** msg, int32_t len) {
int32_t transDecompressMsg(char** msg, int32_t* len) {
STransMsgHead* pHead = (STransMsgHead*)(*msg);
if (pHead->comp == 0) return 0;
@ -68,16 +68,18 @@ int32_t transDecompressMsg(char** msg, int32_t len) {
STransCompMsg* pComp = (STransCompMsg*)pCont;
int32_t oriLen = htonl(pComp->contLen);
char* buf = taosMemoryCalloc(1, oriLen + sizeof(STransMsgHead));
int32_t tlen = *len;
char* buf = taosMemoryCalloc(1, oriLen + sizeof(STransMsgHead));
if (buf == NULL) {
return terrno;
}
STransMsgHead* pNewHead = (STransMsgHead*)buf;
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));
*len = oriLen + sizeof(STransMsgHead);
pNewHead->msgLen = htonl(oriLen + sizeof(STransMsgHead));
taosMemoryFree(pHead);

View File

@ -510,6 +510,12 @@ static bool uvHandleReq(SSvrConn* pConn) {
tError("%s conn %p read invalid packet", transLabel(pInst), pConn);
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) {
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);
}
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->msgLen = htonl(pHead->msgLen);