enh: more error code handle in message encode and decode
This commit is contained in:
parent
8012a1902b
commit
cae63ce673
|
@ -43,22 +43,22 @@
|
||||||
#include "tcol.h"
|
#include "tcol.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
|
|
||||||
#define DECODESQL() \
|
#define DECODESQL() \
|
||||||
do { \
|
do { \
|
||||||
if (!tDecodeIsEnd(&decoder)) { \
|
if (!tDecodeIsEnd(&decoder)) { \
|
||||||
if (tDecodeI32(&decoder, &pReq->sqlLen) < 0) return -1; \
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->sqlLen)); \
|
||||||
if (pReq->sqlLen > 0) { \
|
if (pReq->sqlLen > 0) { \
|
||||||
if (tDecodeBinaryAlloc(&decoder, (void **)&pReq->sql, NULL) < 0) return -1; \
|
TAOS_CHECK_EXIT(tDecodeBinaryAlloc(&decoder, (void **)&pReq->sql, NULL)); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define ENCODESQL() \
|
#define ENCODESQL() \
|
||||||
do { \
|
do { \
|
||||||
if (tEncodeI32(&encoder, pReq->sqlLen) < 0) return -1; \
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->sqlLen)); \
|
||||||
if (pReq->sqlLen > 0) { \
|
if (pReq->sqlLen > 0) { \
|
||||||
if (tEncodeBinary(&encoder, pReq->sql, pReq->sqlLen) < 0) return -1; \
|
TAOS_CHECK_EXIT(tEncodeBinary(&encoder, (const uint8_t *)pReq->sql, pReq->sqlLen)); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define FREESQL() \
|
#define FREESQL() \
|
||||||
|
@ -1243,19 +1243,7 @@ _exit:
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
// int32_t tSerializeSDropTagIdxReq(void *buf, int32_t bufLen, SDropTagIndexReq *pReq) {
|
|
||||||
// SEncoder encoder = {0};
|
|
||||||
// tEncoderInit(&encoder, buf, bufLen);
|
|
||||||
// if (tStartEncode(&encoder) < 0) return -1;
|
|
||||||
// tEndEncode(&encoder);
|
|
||||||
|
|
||||||
// if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
|
||||||
// if (tEncodeI8(&encoder, pReq->igNotExists) < 0) return -1;
|
|
||||||
|
|
||||||
// int32_t tlen = encoder.pos;
|
|
||||||
// tEncoderClear(&encoder);
|
|
||||||
// return tlen;
|
|
||||||
// }
|
|
||||||
int32_t tDeserializeSDropTagIdxReq(void *buf, int32_t bufLen, SDropTagIndexReq *pReq) {
|
int32_t tDeserializeSDropTagIdxReq(void *buf, int32_t bufLen, SDropTagIndexReq *pReq) {
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
@ -1307,32 +1295,6 @@ void tFreeSMCreateFullTextReq(SMCreateFullTextReq *pReq) {
|
||||||
// impl later
|
// impl later
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// int32_t tSerializeSMDropFullTextReq(void *buf, int32_t bufLen, SMDropFullTextReq *pReq) {
|
|
||||||
// SEncoder encoder = {0};
|
|
||||||
// tEncoderInit(&encoder, buf, bufLen);
|
|
||||||
|
|
||||||
// if (tStartEncode(&encoder) < 0) return -1;
|
|
||||||
|
|
||||||
// if (tEncodeCStr(&encoder, pReq->name) < 0) return -1;
|
|
||||||
|
|
||||||
// if (tEncodeI8(&encoder, pReq->igNotExists) < 0) return -1;
|
|
||||||
|
|
||||||
// tEndEncode(&encoder);
|
|
||||||
// int32_t tlen = encoder.pos;
|
|
||||||
// tEncoderClear(&encoder);
|
|
||||||
// return tlen;
|
|
||||||
// }
|
|
||||||
// int32_t tDeserializeSMDropFullTextReq(void *buf, int32_t bufLen, SMDropFullTextReq *pReq) {
|
|
||||||
// SDecoder decoder = {0};
|
|
||||||
// tDecoderInit(&decoder, buf, bufLen);
|
|
||||||
// if (tStartDecode(&decoder) < 0) return -1;
|
|
||||||
// if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1;
|
|
||||||
// if (tDecodeI8(&decoder, &pReq->igNotExists) < 0) return -1;
|
|
||||||
|
|
||||||
// tEndDecode(&decoder);
|
|
||||||
// tDecoderClear(&decoder);
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
int32_t tSerializeSNotifyReq(void *buf, int32_t bufLen, SNotifyReq *pReq) {
|
int32_t tSerializeSNotifyReq(void *buf, int32_t bufLen, SNotifyReq *pReq) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
|
@ -2108,7 +2070,7 @@ int32_t tSerializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq)
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->tabName));
|
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->tabName));
|
||||||
}
|
}
|
||||||
TAOS_CHECK_EXIT(tEncodeBinary(&encoder, pReq->tagCond, pReq->tagCondLen));
|
TAOS_CHECK_EXIT(tEncodeBinary(&encoder, (const uint8_t *)pReq->tagCond, pReq->tagCondLen));
|
||||||
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->numIpRanges));
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->numIpRanges));
|
||||||
for (int32_t i = 0; i < pReq->numIpRanges; ++i) {
|
for (int32_t i = 0; i < pReq->numIpRanges; ++i) {
|
||||||
TAOS_CHECK_EXIT(tEncodeU32(&encoder, pReq->pIpRanges[i].ip));
|
TAOS_CHECK_EXIT(tEncodeU32(&encoder, pReq->pIpRanges[i].ip));
|
||||||
|
@ -3386,6 +3348,8 @@ void tFreeSRetrieveFuncRsp(SRetrieveFuncRsp *pRsp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq) {
|
int32_t tSerializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
int32_t headLen = sizeof(SMsgHead);
|
int32_t headLen = sizeof(SMsgHead);
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
buf = (char *)buf + headLen;
|
buf = (char *)buf + headLen;
|
||||||
|
@ -3395,26 +3359,34 @@ int32_t tSerializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
TAOS_CHECK_EXIT(tStartEncode(&encoder));
|
||||||
if (tEncodeCStr(&encoder, pReq->dbFName) < 0) return -1;
|
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->dbFName));
|
||||||
if (tEncodeCStr(&encoder, pReq->tbName) < 0) return -1;
|
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->tbName));
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
_exit:
|
||||||
tEncoderClear(&encoder);
|
if (code) {
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return code;
|
||||||
|
} else {
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen);
|
SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen);
|
||||||
pHead->vgId = htonl(pReq->header.vgId);
|
pHead->vgId = htonl(pReq->header.vgId);
|
||||||
pHead->contLen = htonl(tlen + headLen);
|
pHead->contLen = htonl(tlen + headLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tlen + headLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tlen + headLen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq) {
|
int32_t tDeserializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq) {
|
||||||
int32_t headLen = sizeof(SMsgHead);
|
int32_t headLen = sizeof(SMsgHead);
|
||||||
|
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
SMsgHead *pHead = buf;
|
SMsgHead *pHead = buf;
|
||||||
pHead->vgId = pReq->header.vgId;
|
pHead->vgId = pReq->header.vgId;
|
||||||
pHead->contLen = pReq->header.contLen;
|
pHead->contLen = pReq->header.contLen;
|
||||||
|
@ -3422,13 +3394,14 @@ int32_t tDeserializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq)
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen);
|
tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen);
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
TAOS_CHECK_EXIT(tStartDecode(&decoder));
|
||||||
if (tDecodeCStrTo(&decoder, pReq->dbFName) < 0) return -1;
|
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->dbFName));
|
||||||
if (tDecodeCStrTo(&decoder, pReq->tbName) < 0) return -1;
|
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->tbName));
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
_exit:
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) {
|
int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) {
|
||||||
|
@ -4683,14 +4656,22 @@ _exit:
|
||||||
|
|
||||||
int32_t tSerializeSTrimDbReq(void *buf, int32_t bufLen, STrimDbReq *pReq) {
|
int32_t tSerializeSTrimDbReq(void *buf, int32_t bufLen, STrimDbReq *pReq) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
|
int32_t tlen;
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
TAOS_CHECK_EXIT(tStartEncode(&encoder));
|
||||||
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->db));
|
||||||
if (tEncodeI32(&encoder, pReq->maxSpeed) < 0) return -1;
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->maxSpeed));
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
_exit:
|
||||||
|
if (code) {
|
||||||
|
tlen = code;
|
||||||
|
} else {
|
||||||
|
tlen = encoder.pos;
|
||||||
|
}
|
||||||
tEncoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
@ -5726,6 +5707,8 @@ void tFreeSSTbHbRsp(SSTbHbRsp *pRsp) {
|
||||||
|
|
||||||
int32_t tSerializeSTableInfoReq(void *buf, int32_t bufLen, STableInfoReq *pReq) {
|
int32_t tSerializeSTableInfoReq(void *buf, int32_t bufLen, STableInfoReq *pReq) {
|
||||||
int32_t headLen = sizeof(SMsgHead);
|
int32_t headLen = sizeof(SMsgHead);
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
buf = (char *)buf + headLen;
|
buf = (char *)buf + headLen;
|
||||||
bufLen -= headLen;
|
bufLen -= headLen;
|
||||||
|
@ -5734,26 +5717,33 @@ int32_t tSerializeSTableInfoReq(void *buf, int32_t bufLen, STableInfoReq *pReq)
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
TAOS_CHECK_EXIT(tStartEncode(&encoder));
|
||||||
if (tEncodeCStr(&encoder, pReq->dbFName) < 0) return -1;
|
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->dbFName));
|
||||||
if (tEncodeCStr(&encoder, pReq->tbName) < 0) return -1;
|
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->tbName));
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
_exit:
|
||||||
tEncoderClear(&encoder);
|
if (code) {
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return code;
|
||||||
|
} else {
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen);
|
SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen);
|
||||||
pHead->vgId = htonl(pReq->header.vgId);
|
pHead->vgId = htonl(pReq->header.vgId);
|
||||||
pHead->contLen = htonl(tlen + headLen);
|
pHead->contLen = htonl(tlen + headLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tlen + headLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tlen + headLen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSTableInfoReq(void *buf, int32_t bufLen, STableInfoReq *pReq) {
|
int32_t tDeserializeSTableInfoReq(void *buf, int32_t bufLen, STableInfoReq *pReq) {
|
||||||
int32_t headLen = sizeof(SMsgHead);
|
int32_t headLen = sizeof(SMsgHead);
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
SMsgHead *pHead = buf;
|
SMsgHead *pHead = buf;
|
||||||
pHead->vgId = pReq->header.vgId;
|
pHead->vgId = pReq->header.vgId;
|
||||||
pHead->contLen = pReq->header.contLen;
|
pHead->contLen = pReq->header.contLen;
|
||||||
|
@ -5761,13 +5751,14 @@ int32_t tDeserializeSTableInfoReq(void *buf, int32_t bufLen, STableInfoReq *pReq
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen);
|
tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen);
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
TAOS_CHECK_EXIT(tStartDecode(&decoder));
|
||||||
if (tDecodeCStrTo(&decoder, pReq->dbFName) < 0) return -1;
|
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->dbFName));
|
||||||
if (tDecodeCStrTo(&decoder, pReq->tbName) < 0) return -1;
|
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->tbName));
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
_exit:
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSMDropTopicReq(void *buf, int32_t bufLen, SMDropTopicReq *pReq) {
|
int32_t tSerializeSMDropTopicReq(void *buf, int32_t bufLen, SMDropTopicReq *pReq) {
|
||||||
|
@ -6393,7 +6384,7 @@ int32_t tSerializeSQueryCompactProgressReq(void *buf, int32_t bufLen, SQueryComp
|
||||||
int32_t tlen;
|
int32_t tlen;
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
TAOS_CHECK_EXIT(tStartEncode(&encoder));
|
||||||
|
|
||||||
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->compactId));
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->compactId));
|
||||||
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->vgId));
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->vgId));
|
||||||
|
@ -7768,7 +7759,9 @@ int32_t tDeserializeSMArbUpdateGroupBatchReq(void *buf, int32_t bufLen, SMArbUpd
|
||||||
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &sz));
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &sz));
|
||||||
|
|
||||||
SArray *updateArray = taosArrayInit(sz, sizeof(SMArbUpdateGroup));
|
SArray *updateArray = taosArrayInit(sz, sizeof(SMArbUpdateGroup));
|
||||||
if (!updateArray) return -1;
|
if (!updateArray) {
|
||||||
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
SMArbUpdateGroup group = {0};
|
SMArbUpdateGroup group = {0};
|
||||||
|
@ -7939,6 +7932,8 @@ void tFreeSExplainRsp(SExplainRsp *pRsp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq) {
|
int32_t tSerializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
int32_t headLen = sizeof(SMsgHead);
|
int32_t headLen = sizeof(SMsgHead);
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
buf = (char *)buf + headLen;
|
buf = (char *)buf + headLen;
|
||||||
|
@ -7947,35 +7942,42 @@ int32_t tSerializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq) {
|
||||||
|
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
TAOS_CHECK_EXIT(tStartEncode(&encoder));
|
||||||
|
|
||||||
int32_t num = taosArrayGetSize(pReq->pMsgs);
|
int32_t num = taosArrayGetSize(pReq->pMsgs);
|
||||||
if (tEncodeI32(&encoder, num) < 0) return -1;
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, num));
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
SBatchMsg *pMsg = taosArrayGet(pReq->pMsgs, i);
|
SBatchMsg *pMsg = taosArrayGet(pReq->pMsgs, i);
|
||||||
if (tEncodeI32(&encoder, pMsg->msgIdx) < 0) return -1;
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pMsg->msgIdx));
|
||||||
if (tEncodeI32(&encoder, pMsg->msgType) < 0) return -1;
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pMsg->msgType));
|
||||||
if (tEncodeI32(&encoder, pMsg->msgLen) < 0) return -1;
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pMsg->msgLen));
|
||||||
if (tEncodeBinary(&encoder, pMsg->msg, pMsg->msgLen) < 0) return -1;
|
TAOS_CHECK_EXIT(tEncodeBinary(&encoder, pMsg->msg, pMsg->msgLen));
|
||||||
}
|
}
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
_exit:
|
||||||
tEncoderClear(&encoder);
|
if (code) {
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
return code;
|
||||||
|
} else {
|
||||||
|
int32_t tlen = encoder.pos;
|
||||||
|
tEncoderClear(&encoder);
|
||||||
|
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen);
|
SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen);
|
||||||
pHead->vgId = htonl(pReq->header.vgId);
|
pHead->vgId = htonl(pReq->header.vgId);
|
||||||
pHead->contLen = htonl(tlen + headLen);
|
pHead->contLen = htonl(tlen + headLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tlen + headLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tlen + headLen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq) {
|
int32_t tDeserializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq) {
|
||||||
int32_t headLen = sizeof(SMsgHead);
|
int32_t headLen = sizeof(SMsgHead);
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t lino;
|
||||||
SMsgHead *pHead = buf;
|
SMsgHead *pHead = buf;
|
||||||
pHead->vgId = pReq->header.vgId;
|
pHead->vgId = pReq->header.vgId;
|
||||||
pHead->contLen = pReq->header.contLen;
|
pHead->contLen = pReq->header.contLen;
|
||||||
|
@ -7983,33 +7985,37 @@ int32_t tDeserializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq) {
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen);
|
tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen);
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
TAOS_CHECK_EXIT(tStartDecode(&decoder));
|
||||||
|
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
if (tDecodeI32(&decoder, &num) < 0) return -1;
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &num));
|
||||||
if (num <= 0) {
|
if (num <= 0) {
|
||||||
pReq->pMsgs = NULL;
|
pReq->pMsgs = NULL;
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pReq->pMsgs = taosArrayInit(num, sizeof(SBatchMsg));
|
pReq->pMsgs = taosArrayInit(num, sizeof(SBatchMsg));
|
||||||
if (NULL == pReq->pMsgs) return -1;
|
if (NULL == pReq->pMsgs) {
|
||||||
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
}
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
SBatchMsg msg = {0};
|
SBatchMsg msg = {0};
|
||||||
if (tDecodeI32(&decoder, &msg.msgIdx) < 0) return -1;
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &msg.msgIdx));
|
||||||
if (tDecodeI32(&decoder, &msg.msgType) < 0) return -1;
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &msg.msgType));
|
||||||
if (tDecodeI32(&decoder, &msg.msgLen) < 0) return -1;
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &msg.msgLen));
|
||||||
if (tDecodeBinaryAlloc(&decoder, &msg.msg, NULL) < 0) return -1;
|
TAOS_CHECK_EXIT(tDecodeBinaryAlloc(&decoder, &msg.msg, NULL));
|
||||||
if (NULL == taosArrayPush(pReq->pMsgs, &msg)) return -1;
|
if (NULL == taosArrayPush(pReq->pMsgs, &msg)) {
|
||||||
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
_exit:
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp) {
|
int32_t tSerializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp) {
|
||||||
|
@ -8169,7 +8175,9 @@ int32_t tDeserializeSMqHbRsp(void *buf, int32_t bufLen, SMqHbRsp *pRsp) {
|
||||||
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &sz));
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &sz));
|
||||||
if (sz > 0) {
|
if (sz > 0) {
|
||||||
pRsp->topicPrivileges = taosArrayInit(sz, sizeof(STopicPrivilege));
|
pRsp->topicPrivileges = taosArrayInit(sz, sizeof(STopicPrivilege));
|
||||||
if (NULL == pRsp->topicPrivileges) return -1;
|
if (NULL == pRsp->topicPrivileges) {
|
||||||
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
}
|
||||||
for (int32_t i = 0; i < sz; ++i) {
|
for (int32_t i = 0; i < sz; ++i) {
|
||||||
STopicPrivilege *data = taosArrayReserve(pRsp->topicPrivileges, 1);
|
STopicPrivilege *data = taosArrayReserve(pRsp->topicPrivileges, 1);
|
||||||
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, data->topic));
|
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, data->topic));
|
||||||
|
@ -8529,7 +8537,7 @@ int32_t tSerializeSResFetchReq(void *buf, int32_t bufLen, SResFetchReq *pReq) {
|
||||||
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->execId));
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->execId));
|
||||||
if (pReq->pOpParam) {
|
if (pReq->pOpParam) {
|
||||||
TAOS_CHECK_EXIT(tEncodeI32(&encoder, 1));
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, 1));
|
||||||
if (tSerializeSOperatorParam(&encoder, pReq->pOpParam) < 0) return -1;
|
TAOS_CHECK_EXIT(tSerializeSOperatorParam(&encoder, pReq->pOpParam));
|
||||||
} else {
|
} else {
|
||||||
TAOS_CHECK_EXIT(tEncodeI32(&encoder, 0));
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, 0));
|
||||||
}
|
}
|
||||||
|
@ -9021,7 +9029,9 @@ int32_t tDeserializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp *
|
||||||
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &num));
|
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &num));
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
pRsp->taskStatus = taosArrayInit(num, sizeof(STaskStatus));
|
pRsp->taskStatus = taosArrayInit(num, sizeof(STaskStatus));
|
||||||
if (NULL == pRsp->taskStatus) return -1;
|
if (NULL == pRsp->taskStatus) {
|
||||||
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
}
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
STaskStatus status = {0};
|
STaskStatus status = {0};
|
||||||
TAOS_CHECK_EXIT(tDecodeU64(&decoder, &status.queryId));
|
TAOS_CHECK_EXIT(tDecodeU64(&decoder, &status.queryId));
|
||||||
|
@ -9289,8 +9299,12 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
|
||||||
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->maxDelay));
|
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->maxDelay));
|
||||||
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->watermark));
|
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->watermark));
|
||||||
TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->igExpired));
|
TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->igExpired));
|
||||||
if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1;
|
if (sqlLen > 0) {
|
||||||
if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1;
|
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->sql));
|
||||||
|
}
|
||||||
|
if (astLen > 0) {
|
||||||
|
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->ast));
|
||||||
|
}
|
||||||
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->numOfTags));
|
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->numOfTags));
|
||||||
for (int32_t i = 0; i < pReq->numOfTags; ++i) {
|
for (int32_t i = 0; i < pReq->numOfTags; ++i) {
|
||||||
SField *pField = taosArrayGet(pReq->pTags, i);
|
SField *pField = taosArrayGet(pReq->pTags, i);
|
||||||
|
@ -9735,7 +9749,9 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) {
|
||||||
TAOS_CHECK_EXIT(tDecodeI32(pCoder, &pReq->commentLen));
|
TAOS_CHECK_EXIT(tDecodeI32(pCoder, &pReq->commentLen));
|
||||||
if (pReq->commentLen > 0) {
|
if (pReq->commentLen > 0) {
|
||||||
pReq->comment = taosMemoryMalloc(pReq->commentLen + 1);
|
pReq->comment = taosMemoryMalloc(pReq->commentLen + 1);
|
||||||
if (pReq->comment == NULL) return -1;
|
if (pReq->comment == NULL) {
|
||||||
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
}
|
||||||
TAOS_CHECK_EXIT(tDecodeCStrTo(pCoder, pReq->comment));
|
TAOS_CHECK_EXIT(tDecodeCStrTo(pCoder, pReq->comment));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10244,7 +10260,9 @@ int32_t tDecodeSVAlterTbRsp(SDecoder *pDecoder, SVAlterTbRsp *pRsp) {
|
||||||
TAOS_CHECK_EXIT(tDecodeI32(pDecoder, &meta));
|
TAOS_CHECK_EXIT(tDecodeI32(pDecoder, &meta));
|
||||||
if (meta) {
|
if (meta) {
|
||||||
pRsp->pMeta = taosMemoryCalloc(1, sizeof(STableMetaRsp));
|
pRsp->pMeta = taosMemoryCalloc(1, sizeof(STableMetaRsp));
|
||||||
if (NULL == pRsp->pMeta) return -1;
|
if (NULL == pRsp->pMeta) {
|
||||||
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
}
|
||||||
TAOS_CHECK_EXIT(tDecodeSTableMetaRsp(pDecoder, pRsp->pMeta));
|
TAOS_CHECK_EXIT(tDecodeSTableMetaRsp(pDecoder, pRsp->pMeta));
|
||||||
}
|
}
|
||||||
tEndDecode(pDecoder);
|
tEndDecode(pDecoder);
|
||||||
|
@ -10275,7 +10293,9 @@ int32_t tDecodeSMAlterStbRsp(SDecoder *pDecoder, SMAlterStbRsp *pRsp) {
|
||||||
TAOS_CHECK_EXIT(tDecodeI32(pDecoder, &meta));
|
TAOS_CHECK_EXIT(tDecodeI32(pDecoder, &meta));
|
||||||
if (meta) {
|
if (meta) {
|
||||||
pRsp->pMeta = taosMemoryCalloc(1, sizeof(STableMetaRsp));
|
pRsp->pMeta = taosMemoryCalloc(1, sizeof(STableMetaRsp));
|
||||||
if (NULL == pRsp->pMeta) return -1;
|
if (NULL == pRsp->pMeta) {
|
||||||
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
}
|
||||||
TAOS_CHECK_EXIT(tDecodeSTableMetaRsp(pDecoder, pRsp->pMeta));
|
TAOS_CHECK_EXIT(tDecodeSTableMetaRsp(pDecoder, pRsp->pMeta));
|
||||||
}
|
}
|
||||||
tEndDecode(pDecoder);
|
tEndDecode(pDecoder);
|
||||||
|
@ -10383,8 +10403,8 @@ int32_t tDecodeSTqOffsetVal(SDecoder *pDecoder, STqOffsetVal *pOffsetVal) {
|
||||||
if (offsetVersion >= TQ_OFFSET_VERSION) {
|
if (offsetVersion >= TQ_OFFSET_VERSION) {
|
||||||
TAOS_CHECK_EXIT(tDecodeI8(pDecoder, &pOffsetVal->primaryKey.type));
|
TAOS_CHECK_EXIT(tDecodeI8(pDecoder, &pOffsetVal->primaryKey.type));
|
||||||
if (IS_VAR_DATA_TYPE(pOffsetVal->primaryKey.type)) {
|
if (IS_VAR_DATA_TYPE(pOffsetVal->primaryKey.type)) {
|
||||||
if (tDecodeBinaryAlloc32(pDecoder, (void **)&pOffsetVal->primaryKey.pData, &pOffsetVal->primaryKey.nData) < 0)
|
TAOS_CHECK_EXIT(
|
||||||
return -1;
|
tDecodeBinaryAlloc32(pDecoder, (void **)&pOffsetVal->primaryKey.pData, &pOffsetVal->primaryKey.nData));
|
||||||
} else {
|
} else {
|
||||||
TAOS_CHECK_EXIT(tDecodeI64(pDecoder, &pOffsetVal->primaryKey.val));
|
TAOS_CHECK_EXIT(tDecodeI64(pDecoder, &pOffsetVal->primaryKey.val));
|
||||||
}
|
}
|
||||||
|
@ -11697,7 +11717,9 @@ int32_t tDeserializeSViewHbRsp(void *buf, int32_t bufLen, SViewHbRsp *pRsp) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfMeta; ++i) {
|
for (int32_t i = 0; i < numOfMeta; ++i) {
|
||||||
SViewMetaRsp *metaRsp = taosMemoryCalloc(1, sizeof(SViewMetaRsp));
|
SViewMetaRsp *metaRsp = taosMemoryCalloc(1, sizeof(SViewMetaRsp));
|
||||||
if (NULL == metaRsp) return -1;
|
if (NULL == metaRsp) {
|
||||||
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
}
|
||||||
TAOS_CHECK_EXIT(tDecodeSViewMetaRsp(&decoder, metaRsp));
|
TAOS_CHECK_EXIT(tDecodeSViewMetaRsp(&decoder, metaRsp));
|
||||||
if (taosArrayPush(pRsp->pViewRsp, &metaRsp) == NULL) {
|
if (taosArrayPush(pRsp->pViewRsp, &metaRsp) == NULL) {
|
||||||
TAOS_CHECK_EXIT(terrno);
|
TAOS_CHECK_EXIT(terrno);
|
||||||
|
|
Loading…
Reference in New Issue