提交 80a32d62 编写于 作者: D dapan1121

fix: fix mbs2ucs4 crash issue in taosd

上级 f1cb48fc
...@@ -62,7 +62,6 @@ typedef int32_t TdUcs4; ...@@ -62,7 +62,6 @@ typedef int32_t TdUcs4;
int32_t taosUcs4len(TdUcs4 *ucs4); int32_t taosUcs4len(TdUcs4 *ucs4);
int64_t taosStr2int64(const char *str); int64_t taosStr2int64(const char *str);
int32_t taosConvInit(int32_t maxNum);
void taosConvDestroy(); void taosConvDestroy();
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs); int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs);
bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len); bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len);
......
...@@ -361,8 +361,6 @@ void taos_init_imp(void) { ...@@ -361,8 +361,6 @@ void taos_init_imp(void) {
initQueryModuleMsgHandle(); initQueryModuleMsgHandle();
taosConvInit(256);
rpcInit(); rpcInit();
SCatalogCfg cfg = {.maxDBCacheNum = 100, .maxTblCacheNum = 100}; SCatalogCfg cfg = {.maxDBCacheNum = 100, .maxTblCacheNum = 100};
......
...@@ -215,6 +215,7 @@ void dmCleanupDnode(SDnode *pDnode) { ...@@ -215,6 +215,7 @@ void dmCleanupDnode(SDnode *pDnode) {
dmClearVars(pDnode); dmClearVars(pDnode);
rpcCleanup(); rpcCleanup();
indexCleanup(); indexCleanup();
taosConvDestroy();
dDebug("dnode is closed, ptr:%p", pDnode); dDebug("dnode is closed, ptr:%p", pDnode);
} }
......
...@@ -143,14 +143,17 @@ SConv *gConv = NULL; ...@@ -143,14 +143,17 @@ SConv *gConv = NULL;
int32_t convUsed = 0; int32_t convUsed = 0;
int32_t gConvMaxNum = 0; int32_t gConvMaxNum = 0;
int32_t taosConvInit(int32_t maxNum) { void taosConvInitImpl(void) {
gConvMaxNum = maxNum * 2; gConvMaxNum = 512;
gConv = taosMemoryCalloc(gConvMaxNum, sizeof(SConv)); gConv = taosMemoryCalloc(gConvMaxNum, sizeof(SConv));
for (int32_t i = 0; i < gConvMaxNum; ++i) { for (int32_t i = 0; i < gConvMaxNum; ++i) {
gConv[i].conv = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset); gConv[i].conv = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset);
} }
}
return 0; static TdThreadOnce convInit = PTHREAD_ONCE_INIT;
void taosConvInit() {
taosThreadOnce(&convInit, taosConvInitImpl);
} }
void taosConvDestroy() { void taosConvDestroy() {
...@@ -162,10 +165,7 @@ void taosConvDestroy() { ...@@ -162,10 +165,7 @@ void taosConvDestroy() {
void taosAcquireConv(int32_t *idx) { void taosAcquireConv(int32_t *idx) {
if (0 == gConvMaxNum) { if (0 == gConvMaxNum) {
gConv = taosMemoryCalloc(1, sizeof(SConv)); taosConvInit();
gConv[0].conv = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset);
*idx = 0;
return;
} }
while (true) { while (true) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册