提交 7425820c 编写于 作者: H Haojun Liao

refactor: do some internal refactor.

上级 a9ed671d
......@@ -52,6 +52,20 @@ typedef struct STraceId {
sprintf(buf, "0x%" PRIx64 ":0x%" PRIx64 "", rootId, msgId); \
} while (0)
#define TRACE_TO_STR_(_traceId, _buf) \
do { \
int64_t rootId = (_traceId) != NULL ? (_traceId)->rootId : 0; \
int64_t msgId = (_traceId) != NULL ? (_traceId)->msgId : 0; \
char* _t = _buf; \
_t[0] = '0'; \
_t[1] = 'x'; \
_t += titoa(rootId, 16, &_t[2]); \
_t[0] = ':'; \
_t[1] = '0'; \
_t[2] = 'x'; \
_t += titoa(msgId, 16, &_t[3]); \
} while (0)
#ifdef __cplusplus
}
#endif
......
......@@ -47,7 +47,7 @@ int32_t taosByteArrayToHexStr(char bytes[], int32_t len, char hexstr[]);
int32_t taosHexStrToByteArray(char hexstr[], char bytes[]);
int32_t tintToHex(uint64_t val, char hex[]);
int32_t tintToStr(uint64_t val, size_t radix, char str[]);
int32_t titoa(uint64_t val, size_t radix, char str[]);
char *taosIpStr(uint32_t ipInt);
uint32_t ip2uint(const char *const ip_addr);
......
......@@ -1371,7 +1371,7 @@ int32_t doProcessMsgFromServer(void* param) {
STraceId* trace = &pMsg->info.traceId;
char tbuf[40] = {0};
TRACE_TO_STR(trace, tbuf);
TRACE_TO_STR_(trace, tbuf);
tscDebug("processMsgFromServer handle %p, message: %s, size:%d, code: %s, gtid: %s", pMsg->info.handle,
TMSG_INFO(pMsg->msgType), pMsg->contLen, tstrerror(pMsg->code), tbuf);
......
......@@ -108,15 +108,15 @@ void tsdbHeadFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SHeadFile *pHeadF,
*(p++) = TD_DIRSEP[0];
*(p++) = 'v';
p += tintToStr(TD_VID(pTsdb->pVnode), 10, p);
p += titoa(TD_VID(pTsdb->pVnode), 10, p);
*(p++) = 'f';
p += tintToStr(fid, 10, p);
p += titoa(fid, 10, p);
memcpy(p, "ver", 3);
p += 3;
p += tintToStr(pHeadF->commitID, 10, p);
p += titoa(pHeadF->commitID, 10, p);
memcpy(p, ".head", 5);
p[5] = 0;
}
......
......@@ -336,7 +336,7 @@ int32_t tintToHex(uint64_t val, char hex[]) {
return j;
}
int32_t tintToStr(uint64_t val, size_t radix, char str[]) {
int32_t titoa(uint64_t val, size_t radix, char str[]) {
if (radix < 2 || radix > 16) {
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册