Merge pull request #27484 from taosdata/fix/TD-31696
fix:[TD-31696] decimal number check error in config file because precision different in float and double
This commit is contained in:
commit
968b90c1eb
|
@ -84,11 +84,11 @@ typedef struct SConfigItem {
|
|||
};
|
||||
union {
|
||||
int64_t imin;
|
||||
double fmin;
|
||||
float fmin;
|
||||
};
|
||||
union {
|
||||
int64_t imax;
|
||||
double fmax;
|
||||
float fmax;
|
||||
};
|
||||
SArray *array; // SDiskCfg/SLogVar
|
||||
} SConfigItem;
|
||||
|
|
|
@ -55,7 +55,7 @@ void taosIpPort2String(uint32_t ip, uint16_t port, char *str);
|
|||
|
||||
void *tmemmem(const char *haystack, int hlen, const char *needle, int nlen);
|
||||
|
||||
int32_t parseCfgReal(const char *str, double *out);
|
||||
int32_t parseCfgReal(const char *str, float *out);
|
||||
|
||||
static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) {
|
||||
T_MD5_CTX context;
|
||||
|
|
|
@ -696,7 +696,7 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId) {
|
|||
continue;
|
||||
}
|
||||
if (taosLockFile(pFile) < 0) {
|
||||
tscError("failed to lock file:%s since %s, maybe used by other process", filename, terrstr());
|
||||
tscInfo("failed to lock file:%s since %s, maybe used by other process", filename, terrstr());
|
||||
(void)taosCloseFile(&pFile);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -193,15 +193,15 @@ static int32_t cfgSetInt64(SConfigItem *pItem, const char *value, ECfgSrcType st
|
|||
}
|
||||
|
||||
static int32_t cfgSetFloat(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
||||
double dval;
|
||||
float dval = 0;
|
||||
TAOS_CHECK_RETURN(parseCfgReal(value, &dval));
|
||||
if (dval < pItem->fmin || dval > pItem->fmax) {
|
||||
uError("cfg:%s, type:%s src:%s value:%f out of range[%f, %f]", pItem->name, cfgDtypeStr(pItem->dtype),
|
||||
uError("cfg:%s, type:%s src:%s value:%g out of range[%g, %g]", pItem->name, cfgDtypeStr(pItem->dtype),
|
||||
cfgStypeStr(stype), dval, pItem->fmin, pItem->fmax);
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
pItem->fval = (float)dval;
|
||||
pItem->fval = dval;
|
||||
pItem->stype = stype;
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
@ -385,6 +385,10 @@ int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcTy
|
|||
(void)taosThreadMutexUnlock(&pCfg->lock);
|
||||
}
|
||||
|
||||
if (code != 0){
|
||||
uError("cfg:%s, type:%s src:%s value:%s failed since %s", pItem->name, cfgDtypeStr(pItem->dtype),
|
||||
cfgStypeStr(stype), value, tstrerror(code));
|
||||
}
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
|
@ -475,14 +479,14 @@ int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *p
|
|||
} break;
|
||||
case CFG_DTYPE_FLOAT:
|
||||
case CFG_DTYPE_DOUBLE: {
|
||||
double dval;
|
||||
float dval = 0;
|
||||
int32_t code = parseCfgReal(pVal, &dval);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
cfgUnLock(pCfg);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
if (dval < pItem->fmin || dval > pItem->fmax) {
|
||||
uError("cfg:%s, type:%s value:%f out of range[%f, %f]", pItem->name, cfgDtypeStr(pItem->dtype), dval,
|
||||
uError("cfg:%s, type:%s value:%g out of range[%g, %g]", pItem->name, cfgDtypeStr(pItem->dtype), dval,
|
||||
pItem->fmin, pItem->fmax);
|
||||
cfgUnLock(pCfg);
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
|
|
|
@ -505,11 +505,11 @@ size_t twcsncspn(const TdUcs4 *wcs, size_t size, const TdUcs4 *reject, size_t rs
|
|||
return index;
|
||||
}
|
||||
|
||||
int32_t parseCfgReal(const char *str, double *out) {
|
||||
double val;
|
||||
int32_t parseCfgReal(const char *str, float *out) {
|
||||
float val;
|
||||
char *endPtr;
|
||||
errno = 0;
|
||||
val = taosStr2Double(str, &endPtr);
|
||||
val = taosStr2Float(str, &endPtr);
|
||||
if (str == endPtr || errno == ERANGE || isnan(val)) {
|
||||
return terrno = TSDB_CODE_INVALID_CFG_VALUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue