refact some code
This commit is contained in:
parent
279bfb4de0
commit
b88ff0f455
|
@ -46,8 +46,10 @@ const char* terrstr();
|
||||||
char* taosGetErrMsgReturn();
|
char* taosGetErrMsgReturn();
|
||||||
char* taosGetErrMsg();
|
char* taosGetErrMsg();
|
||||||
int32_t* taosGetErrno();
|
int32_t* taosGetErrno();
|
||||||
|
int32_t* taosGetErrln();
|
||||||
int32_t taosGetErrSize();
|
int32_t taosGetErrSize();
|
||||||
#define terrno (*taosGetErrno())
|
#define terrno (*taosGetErrno())
|
||||||
|
#define terrln (*taosGetErrln())
|
||||||
#define terrMsg (taosGetErrMsg())
|
#define terrMsg (taosGetErrMsg())
|
||||||
|
|
||||||
#define SET_ERROR_MSG(MSG, ...) \
|
#define SET_ERROR_MSG(MSG, ...) \
|
||||||
|
|
|
@ -117,6 +117,15 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TAOS_CHECK_ERRNO(CODE) \
|
||||||
|
do { \
|
||||||
|
terrno = (CODE); \
|
||||||
|
if (terrno != TSDB_CODE_SUCCESS) { \
|
||||||
|
terrln = __LINE__; \
|
||||||
|
goto _exit; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define TSDB_CHECK_CODE(CODE, LINO, LABEL) \
|
#define TSDB_CHECK_CODE(CODE, LINO, LABEL) \
|
||||||
do { \
|
do { \
|
||||||
if (TSDB_CODE_SUCCESS != (CODE)) { \
|
if (TSDB_CODE_SUCCESS != (CODE)) { \
|
||||||
|
|
|
@ -5737,65 +5737,74 @@ _exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSAlterVnodeConfigReq(void *buf, int32_t bufLen, SAlterVnodeConfigReq *pReq) {
|
int32_t tSerializeSAlterVnodeConfigReq(void *buf, int32_t bufLen, SAlterVnodeConfigReq *pReq) {
|
||||||
|
int32_t tlen;
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
|
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartEncode(&encoder) < 0) return -1;
|
TAOS_CHECK_ERRNO(tStartEncode(&encoder));
|
||||||
if (tEncodeI32(&encoder, pReq->vgVersion) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI32(&encoder, pReq->vgVersion));
|
||||||
if (tEncodeI32(&encoder, pReq->buffer) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI32(&encoder, pReq->buffer));
|
||||||
if (tEncodeI32(&encoder, pReq->pageSize) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI32(&encoder, pReq->pageSize));
|
||||||
if (tEncodeI32(&encoder, pReq->pages) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI32(&encoder, pReq->pages));
|
||||||
if (tEncodeI32(&encoder, pReq->cacheLastSize) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI32(&encoder, pReq->cacheLastSize));
|
||||||
if (tEncodeI32(&encoder, pReq->daysPerFile) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI32(&encoder, pReq->daysPerFile));
|
||||||
if (tEncodeI32(&encoder, pReq->daysToKeep0) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI32(&encoder, pReq->daysToKeep0));
|
||||||
if (tEncodeI32(&encoder, pReq->daysToKeep1) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI32(&encoder, pReq->daysToKeep1));
|
||||||
if (tEncodeI32(&encoder, pReq->daysToKeep2) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI32(&encoder, pReq->daysToKeep2));
|
||||||
if (tEncodeI32(&encoder, pReq->walFsyncPeriod) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI32(&encoder, pReq->walFsyncPeriod));
|
||||||
if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI8(&encoder, pReq->walLevel));
|
||||||
if (tEncodeI8(&encoder, pReq->strict) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI8(&encoder, pReq->strict));
|
||||||
if (tEncodeI8(&encoder, pReq->cacheLast) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI8(&encoder, pReq->cacheLast));
|
||||||
for (int32_t i = 0; i < 7; ++i) {
|
for (int32_t i = 0; i < 7; ++i) {
|
||||||
if (tEncodeI64(&encoder, pReq->reserved[i]) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI64(&encoder, pReq->reserved[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1st modification
|
// 1st modification
|
||||||
if (tEncodeI16(&encoder, pReq->sttTrigger) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI16(&encoder, pReq->sttTrigger));
|
||||||
if (tEncodeI32(&encoder, pReq->minRows) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI32(&encoder, pReq->minRows));
|
||||||
// 2nd modification
|
// 2nd modification
|
||||||
if (tEncodeI32(&encoder, pReq->walRetentionPeriod) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI32(&encoder, pReq->walRetentionPeriod));
|
||||||
if (tEncodeI32(&encoder, pReq->walRetentionSize) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI32(&encoder, pReq->walRetentionSize));
|
||||||
if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI32(&encoder, pReq->keepTimeOffset));
|
||||||
|
|
||||||
if (tEncodeI32(&encoder, pReq->s3KeepLocal) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI32(&encoder, pReq->s3KeepLocal));
|
||||||
if (tEncodeI8(&encoder, pReq->s3Compact) < 0) return -1;
|
TAOS_CHECK_ERRNO(tEncodeI8(&encoder, pReq->s3Compact));
|
||||||
|
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
_exit:
|
||||||
|
if (terrno) {
|
||||||
|
uError("%s failed at line %d since %s", __func__, terrln, terrstr());
|
||||||
|
tlen = -1;
|
||||||
|
} else {
|
||||||
|
tlen = encoder.pos;
|
||||||
|
}
|
||||||
tEncoderClear(&encoder);
|
tEncoderClear(&encoder);
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tDeserializeSAlterVnodeConfigReq(void *buf, int32_t bufLen, SAlterVnodeConfigReq *pReq) {
|
int32_t tDeserializeSAlterVnodeConfigReq(void *buf, int32_t bufLen, SAlterVnodeConfigReq *pReq) {
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
|
|
||||||
tDecoderInit(&decoder, buf, bufLen);
|
tDecoderInit(&decoder, buf, bufLen);
|
||||||
|
|
||||||
if (tStartDecode(&decoder) < 0) return -1;
|
TAOS_CHECK_ERRNO(tStartDecode(&decoder));
|
||||||
if (tDecodeI32(&decoder, &pReq->vgVersion) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI32(&decoder, &pReq->vgVersion));
|
||||||
if (tDecodeI32(&decoder, &pReq->buffer) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI32(&decoder, &pReq->buffer));
|
||||||
if (tDecodeI32(&decoder, &pReq->pageSize) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI32(&decoder, &pReq->pageSize));
|
||||||
if (tDecodeI32(&decoder, &pReq->pages) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI32(&decoder, &pReq->pages));
|
||||||
if (tDecodeI32(&decoder, &pReq->cacheLastSize) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI32(&decoder, &pReq->cacheLastSize));
|
||||||
if (tDecodeI32(&decoder, &pReq->daysPerFile) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI32(&decoder, &pReq->daysPerFile));
|
||||||
if (tDecodeI32(&decoder, &pReq->daysToKeep0) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI32(&decoder, &pReq->daysToKeep0));
|
||||||
if (tDecodeI32(&decoder, &pReq->daysToKeep1) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI32(&decoder, &pReq->daysToKeep1));
|
||||||
if (tDecodeI32(&decoder, &pReq->daysToKeep2) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI32(&decoder, &pReq->daysToKeep2));
|
||||||
if (tDecodeI32(&decoder, &pReq->walFsyncPeriod) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI32(&decoder, &pReq->walFsyncPeriod));
|
||||||
if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI8(&decoder, &pReq->walLevel));
|
||||||
if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI8(&decoder, &pReq->strict));
|
||||||
if (tDecodeI8(&decoder, &pReq->cacheLast) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI8(&decoder, &pReq->cacheLast));
|
||||||
for (int32_t i = 0; i < 7; ++i) {
|
for (int32_t i = 0; i < 7; ++i) {
|
||||||
if (tDecodeI64(&decoder, &pReq->reserved[i]) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI64(&decoder, &pReq->reserved[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1st modification
|
// 1st modification
|
||||||
|
@ -5803,8 +5812,8 @@ int32_t tDeserializeSAlterVnodeConfigReq(void *buf, int32_t bufLen, SAlterVnodeC
|
||||||
pReq->sttTrigger = -1;
|
pReq->sttTrigger = -1;
|
||||||
pReq->minRows = -1;
|
pReq->minRows = -1;
|
||||||
} else {
|
} else {
|
||||||
if (tDecodeI16(&decoder, &pReq->sttTrigger) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI16(&decoder, &pReq->sttTrigger));
|
||||||
if (tDecodeI32(&decoder, &pReq->minRows) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI32(&decoder, &pReq->minRows));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2n modification
|
// 2n modification
|
||||||
|
@ -5812,24 +5821,29 @@ int32_t tDeserializeSAlterVnodeConfigReq(void *buf, int32_t bufLen, SAlterVnodeC
|
||||||
pReq->walRetentionPeriod = -1;
|
pReq->walRetentionPeriod = -1;
|
||||||
pReq->walRetentionSize = -1;
|
pReq->walRetentionSize = -1;
|
||||||
} else {
|
} else {
|
||||||
if (tDecodeI32(&decoder, &pReq->walRetentionPeriod) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI32(&decoder, &pReq->walRetentionPeriod));
|
||||||
if (tDecodeI32(&decoder, &pReq->walRetentionSize) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI32(&decoder, &pReq->walRetentionSize));
|
||||||
}
|
}
|
||||||
pReq->keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET;
|
pReq->keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET;
|
||||||
if (!tDecodeIsEnd(&decoder)) {
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
if (tDecodeI32(&decoder, &pReq->keepTimeOffset) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI32(&decoder, &pReq->keepTimeOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
pReq->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
|
pReq->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
|
||||||
pReq->s3Compact = TSDB_DEFAULT_S3_COMPACT;
|
pReq->s3Compact = TSDB_DEFAULT_S3_COMPACT;
|
||||||
if (!tDecodeIsEnd(&decoder)) {
|
if (!tDecodeIsEnd(&decoder)) {
|
||||||
if (tDecodeI32(&decoder, &pReq->s3KeepLocal) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI32(&decoder, &pReq->s3KeepLocal) < 0);
|
||||||
if (tDecodeI8(&decoder, &pReq->s3Compact) < 0) return -1;
|
TAOS_CHECK_ERRNO(tDecodeI8(&decoder, &pReq->s3Compact) < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
|
_exit:
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
return 0;
|
if (terrno) {
|
||||||
|
uError("%s failed at line %d since %s", __func__, terrln, terrstr());
|
||||||
|
}
|
||||||
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tSerializeSAlterVnodeReplicaReq(void *buf, int32_t bufLen, SAlterVnodeReplicaReq *pReq) {
|
int32_t tSerializeSAlterVnodeReplicaReq(void *buf, int32_t bufLen, SAlterVnodeReplicaReq *pReq) {
|
||||||
|
@ -9341,7 +9355,6 @@ int32_t tDecodeSMqRebVgReq(SDecoder* pCoder, SMqRebVgReq* pReq) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t tEncodeDeleteRes(SEncoder *pCoder, const SDeleteRes *pRes) {
|
int32_t tEncodeDeleteRes(SEncoder *pCoder, const SDeleteRes *pRes) {
|
||||||
int32_t nUid = taosArrayGetSize(pRes->uidList);
|
int32_t nUid = taosArrayGetSize(pRes->uidList);
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,12 @@
|
||||||
#define TAOS_ERROR_C
|
#define TAOS_ERROR_C
|
||||||
|
|
||||||
static threadlocal int32_t tsErrno;
|
static threadlocal int32_t tsErrno;
|
||||||
|
static threadlocal int32_t tsErrln;
|
||||||
static threadlocal char tsErrMsgDetail[ERR_MSG_LEN] = {0};
|
static threadlocal char tsErrMsgDetail[ERR_MSG_LEN] = {0};
|
||||||
static threadlocal char tsErrMsgReturn[ERR_MSG_LEN] = {0};
|
static threadlocal char tsErrMsgReturn[ERR_MSG_LEN] = {0};
|
||||||
|
|
||||||
int32_t* taosGetErrno() { return &tsErrno; }
|
int32_t* taosGetErrno() { return &tsErrno; }
|
||||||
|
int32_t* taosGetErrln() { return &tsErrln; }
|
||||||
char* taosGetErrMsg() { return tsErrMsgDetail; }
|
char* taosGetErrMsg() { return tsErrMsgDetail; }
|
||||||
char* taosGetErrMsgReturn() { return tsErrMsgReturn; }
|
char* taosGetErrMsgReturn() { return tsErrMsgReturn; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue