diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 80bf48364c2c634a47122b0834f07d8c229c0ef7..4ed4e0473bdf3c11c2838842b24c15d886a02f2e 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -430,10 +430,10 @@ static void doInitGlobalConfig(void) { // port cfg.option = "serverPort"; cfg.ptr = &tsServerPort; - cfg.valType = TAOS_CFG_VTYPE_INT16; + cfg.valType = TAOS_CFG_VTYPE_UINT16; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT; cfg.minValue = 1; - cfg.maxValue = 65535; + cfg.maxValue = 65056; cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); diff --git a/src/dnode/src/dnodeCheck.c b/src/dnode/src/dnodeCheck.c index 94d23609505bf952225b8dd2c752754dbd5d55b9..87baff30673afc68eb23a00bef279433a422ba67 100644 --- a/src/dnode/src/dnodeCheck.c +++ b/src/dnode/src/dnodeCheck.c @@ -29,7 +29,7 @@ typedef struct { static SCheckItem tsCheckItem[TSDB_CHECK_ITEM_MAX] = {{0}}; int64_t tsMinFreeMemSizeForStart = 0; -static int32_t bindTcpPort(int16_t port) { +static int32_t bindTcpPort(uint16_t port) { SOCKET serverSocket; struct sockaddr_in server_addr; @@ -85,9 +85,9 @@ static int32_t bindUdpPort(int16_t port) { static int32_t dnodeCheckNetwork() { int32_t ret; - int16_t startPort = tsServerPort; + uint16_t startPort = tsServerPort; - for (int16_t port = startPort; port < startPort + 12; port++) { + for (uint16_t port = startPort; port < startPort + 12; port++) { ret = bindTcpPort(port); if (0 != ret) { dError("failed to tcp bind port %d, quit", port); diff --git a/src/util/inc/tconfig.h b/src/util/inc/tconfig.h index 9923409885fad30cbadd9354349075708b1a7fda..fdb2595fd8d3b1659800ca3a5b88c32b6fe95e93 100644 --- a/src/util/inc/tconfig.h +++ b/src/util/inc/tconfig.h @@ -44,6 +44,7 @@ enum { TAOS_CFG_VTYPE_INT8, TAOS_CFG_VTYPE_INT16, TAOS_CFG_VTYPE_INT32, + TAOS_CFG_VTYPE_UINT16, TAOS_CFG_VTYPE_FLOAT, TAOS_CFG_VTYPE_STRING, TAOS_CFG_VTYPE_IPSTR, diff --git a/src/util/src/tconfig.c b/src/util/src/tconfig.c index 7a92750f8f2e89a93557d367b0c4772a2faaa57d..c4bd57760222ac3da7d25510cc2f434fe0cf0cac 100644 --- a/src/util/src/tconfig.c +++ b/src/util/src/tconfig.c @@ -95,6 +95,23 @@ static void taosReadInt16Config(SGlobalCfg *cfg, char *input_value) { } } +static void taosReadUInt16Config(SGlobalCfg *cfg, char *input_value) { + int32_t value = atoi(input_value); + uint16_t *option = (uint16_t *)cfg->ptr; + if (value < cfg->minValue || value > cfg->maxValue) { + uError("config option:%s, input value:%s, out of range[%f, %f], use default value:%d", + cfg->option, input_value, cfg->minValue, cfg->maxValue, *option); + } else { + if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) { + *option = (uint16_t)value; + cfg->cfgStatus = TAOS_CFG_CSTATUS_FILE; + } else { + uWarn("config option:%s, input value:%s, is configured by %s, use %d", cfg->option, input_value, + tsCfgStatusStr[cfg->cfgStatus], *option); + } + } +} + static void taosReadInt8Config(SGlobalCfg *cfg, char *input_value) { int32_t value = atoi(input_value); int8_t *option = (int8_t *)cfg->ptr; @@ -239,6 +256,9 @@ static void taosReadConfigOption(const char *option, char *value, char *value2, case TAOS_CFG_VTYPE_INT32: taosReadInt32Config(cfg, value); break; + case TAOS_CFG_VTYPE_UINT16: + taosReadUInt16Config(cfg, value); + break; case TAOS_CFG_VTYPE_FLOAT: taosReadFloatConfig(cfg, value); break; @@ -422,6 +442,9 @@ void taosPrintGlobalCfg() { case TAOS_CFG_VTYPE_INT32: uInfo(" %s:%s%d%s", cfg->option, blank, *((int32_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]); break; + case TAOS_CFG_VTYPE_UINT16: + uInfo(" %s:%s%d%s", cfg->option, blank, *((uint16_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]); + break; case TAOS_CFG_VTYPE_FLOAT: uInfo(" %s:%s%f%s", cfg->option, blank, *((float *)cfg->ptr), tsGlobalUnit[cfg->unitType]); break; @@ -459,6 +482,9 @@ static void taosDumpCfg(SGlobalCfg *cfg) { case TAOS_CFG_VTYPE_INT32: printf(" %s:%s%d%s\n", cfg->option, blank, *((int32_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]); break; + case TAOS_CFG_VTYPE_UINT16: + printf(" %s:%s%d%s\n", cfg->option, blank, *((uint16_t *)cfg->ptr), tsGlobalUnit[cfg->unitType]); + break; case TAOS_CFG_VTYPE_FLOAT: printf(" %s:%s%f%s\n", cfg->option, blank, *((float *)cfg->ptr), tsGlobalUnit[cfg->unitType]); break;