fix: fix mbs2ucs4 crash issue in taosd
This commit is contained in:
parent
f1cb48fc08
commit
80a32d6235
|
@ -62,7 +62,6 @@ typedef int32_t TdUcs4;
|
|||
int32_t taosUcs4len(TdUcs4 *ucs4);
|
||||
int64_t taosStr2int64(const char *str);
|
||||
|
||||
int32_t taosConvInit(int32_t maxNum);
|
||||
void taosConvDestroy();
|
||||
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);
|
||||
|
|
|
@ -361,8 +361,6 @@ void taos_init_imp(void) {
|
|||
|
||||
initQueryModuleMsgHandle();
|
||||
|
||||
taosConvInit(256);
|
||||
|
||||
rpcInit();
|
||||
|
||||
SCatalogCfg cfg = {.maxDBCacheNum = 100, .maxTblCacheNum = 100};
|
||||
|
|
|
@ -215,6 +215,7 @@ void dmCleanupDnode(SDnode *pDnode) {
|
|||
dmClearVars(pDnode);
|
||||
rpcCleanup();
|
||||
indexCleanup();
|
||||
taosConvDestroy();
|
||||
dDebug("dnode is closed, ptr:%p", pDnode);
|
||||
}
|
||||
|
||||
|
|
|
@ -143,14 +143,17 @@ SConv *gConv = NULL;
|
|||
int32_t convUsed = 0;
|
||||
int32_t gConvMaxNum = 0;
|
||||
|
||||
int32_t taosConvInit(int32_t maxNum) {
|
||||
gConvMaxNum = maxNum * 2;
|
||||
void taosConvInitImpl(void) {
|
||||
gConvMaxNum = 512;
|
||||
gConv = taosMemoryCalloc(gConvMaxNum, sizeof(SConv));
|
||||
for (int32_t i = 0; i < gConvMaxNum; ++i) {
|
||||
gConv[i].conv = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
static TdThreadOnce convInit = PTHREAD_ONCE_INIT;
|
||||
void taosConvInit() {
|
||||
taosThreadOnce(&convInit, taosConvInitImpl);
|
||||
}
|
||||
|
||||
void taosConvDestroy() {
|
||||
|
@ -162,10 +165,7 @@ void taosConvDestroy() {
|
|||
|
||||
void taosAcquireConv(int32_t *idx) {
|
||||
if (0 == gConvMaxNum) {
|
||||
gConv = taosMemoryCalloc(1, sizeof(SConv));
|
||||
gConv[0].conv = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset);
|
||||
*idx = 0;
|
||||
return;
|
||||
taosConvInit();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
|
|
Loading…
Reference in New Issue