From ec86e48bccd8ac7ac17f8624b9ce0779a0dd7c61 Mon Sep 17 00:00:00 2001 From: xieyinglin Date: Tue, 19 Nov 2019 23:46:41 +0800 Subject: [PATCH 1/8] fix for issue #745 --- .../jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java index 7881c06b6a..c297fb67b0 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java @@ -273,6 +273,9 @@ public class TSDBDriver implements java.sql.Driver { String user = ""; for (String queryStr : queryStrings) { String[] kvPair = queryStr.trim().split("="); + if (kvPair.length < 2){ + continue; + } switch (kvPair[0].toLowerCase()) { case PROPERTY_KEY_USER: urlProps.setProperty(PROPERTY_KEY_USER, kvPair[1]); From 85bdad282bc6f843039ed93986aea42d41cc97a0 Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Wed, 20 Nov 2019 10:34:05 +0800 Subject: [PATCH 2/8] [TBASE-1197]fix memory realloc bug --- src/client/inc/tscUtil.h | 2 ++ src/client/src/tscLocal.c | 2 +- src/client/src/tscUtil.c | 3 ++- src/util/src/tnote.c | 16 ---------------- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index a0c16f062d..e0c073d153 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -106,6 +106,8 @@ void tscAddSpecialColumnForSelect(SSqlCmd* pCmd, int32_t outputColIndex, int16_t SSchema* pColSchema, int16_t isTag); void addRequiredTagColumn(SSqlCmd* pCmd, int32_t tagColIndex, int32_t tableIndex); + +//TODO refactor, remove void SStringFree(SString* str); void SStringCopy(SString* pDest, const SString* pSrc); SString SStringCreate(const char* str); diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index d217d09588..a18a98c8c1 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -26,7 +26,7 @@ #include "tschemautil.h" #include "tsocket.h" -static int32_t getToStringLength(char *pData, int32_t length, int32_t type) { +static int32_t getToStringLength(const char *pData, int32_t length, int32_t type) { char buf[512] = {0}; int32_t len = 0; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index fd23b183b1..25564a75ea 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1643,7 +1643,7 @@ int32_t SStringEnsureRemain(SString* pStr, int32_t size) { } // remain space is insufficient, allocate more spaces - int32_t inc = (size < MIN_ALLOC_SIZE) ? size : MIN_ALLOC_SIZE; + int32_t inc = (size >= MIN_ALLOC_SIZE) ? size : MIN_ALLOC_SIZE; if (inc < (pStr->alloc >> 1)) { inc = (pStr->alloc >> 1); } @@ -1670,6 +1670,7 @@ int32_t SStringEnsureRemain(SString* pStr, int32_t size) { } memset(tmp + pStr->n, 0, inc); + pStr->alloc = newsize; pStr->z = tmp; return TSDB_CODE_SUCCESS; diff --git a/src/util/src/tnote.c b/src/util/src/tnote.c index 68228d377a..709ac2742e 100644 --- a/src/util/src/tnote.c +++ b/src/util/src/tnote.c @@ -13,22 +13,6 @@ * along with this program. If not, see . */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "os.h" #include "tutil.h" #include "tglobalcfg.h" From 1895b2ff98b561c094dd346eb72b3b33ac4f4219 Mon Sep 17 00:00:00 2001 From: lihui Date: Wed, 20 Nov 2019 11:55:11 +0800 Subject: [PATCH 3/8] [TBASE-1198] --- src/rpc/src/trpc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpc/src/trpc.c b/src/rpc/src/trpc.c index 5403caac9d..3aa50cf168 100644 --- a/src/rpc/src/trpc.c +++ b/src/rpc/src/trpc.c @@ -1075,6 +1075,7 @@ void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, short port, // parsing error if (pHeader->msgType & 1) { + memset(pReply, 0, sizeof(pReply)); msgLen = taosBuildErrorMsgToPeer(data, code, pReply); (*taosSendData[pServer->type])(ip, port, pReply, msgLen, chandle); tTrace("%s cid:%d sid:%d id:%s, %s is sent with error code:%u pConn:%p", pServer->label, chann, sid, From 403bc1b56b705e0ecfb33da57ea6b4f7d408e588 Mon Sep 17 00:00:00 2001 From: malong Date: Wed, 20 Nov 2019 13:20:13 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E6=97=B6=E9=97=B4=E7=BB=B4=E5=BA=A6?= =?UTF-8?q?=E8=81=9A=E5=90=88=E7=9A=84=E5=AE=9E=E4=BE=8B=E4=B8=AD=20group?= =?UTF-8?q?=20by=E5=92=8Cfill=20=E9=A1=BA=E5=BA=8F=E5=86=99=E5=8F=8D?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- documentation/tdenginedocs-cn/taos-sql/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/tdenginedocs-cn/taos-sql/index.html b/documentation/tdenginedocs-cn/taos-sql/index.html index ec3e42d090..207bfe03fd 100644 --- a/documentation/tdenginedocs-cn/taos-sql/index.html +++ b/documentation/tdenginedocs-cn/taos-sql/index.html @@ -359,9 +359,9 @@ SELECT function_list FROM tb_name SELECT function_list FROM stb_name [WHERE where_condition] - [GROUP BY tags] + [FILL ({ VALUE | PREV | NULL | LINEAR})] INTERVAL (interval) - [FILL ({ VALUE | PREV | NULL | LINEAR})] + [GROUP BY tags]
  • 聚合时间段的长度由关键词INTERVAL指定,最短时间间隔10毫秒(10a)。聚合查询中,能够同时执行的聚合和选择函数仅限于单个输出的函数:count、avg、sum 、stddev、leastsquares、percentile、min、max、first、last,不能使用具有多行输出结果的函数(例如:top、bottom、diff以及四则运算)。
  • WHERE语句可以指定查询的起止时间和其他过滤条件
  • From 3980d488e30d7e653e25abc89d9061049ef6dee6 Mon Sep 17 00:00:00 2001 From: lihui Date: Wed, 20 Nov 2019 13:27:28 +0800 Subject: [PATCH 5/8] [TBASE-1199] --- src/client/inc/tscCache.h | 4 +- src/client/inc/tscUtil.h | 2 +- src/client/inc/tsclient.h | 2 +- src/client/src/tscCache.c | 16 +++--- src/client/src/tscProfile.c | 2 +- src/client/src/tscSQLParser.c | 2 +- src/client/src/tscSql.c | 6 +-- src/inc/sdb.h | 4 +- src/inc/taos.h | 2 +- src/inc/taosmsg.h | 2 +- src/inc/tglobalcfg.h | 14 +++--- src/inc/trpc.h | 6 +-- src/inc/tsocket.h | 10 ++-- src/kit/taosdemo/taosdemo.c | 6 +-- src/kit/taosdump/taosdump.c | 2 +- src/modules/http/inc/httpHandle.h | 4 +- src/modules/http/src/httpSql.c | 2 +- src/modules/monitor/src/monitorSystem.c | 2 +- src/os/darwin/src/tdarwin.c | 18 +++---- src/os/linux/src/tlinux.c | 8 +-- src/os/windows/src/twintcpclient.c | 6 +-- src/os/windows/src/twintcpserver.c | 4 +- src/rpc/inc/thaship.h | 6 +-- src/rpc/inc/ttcpclient.h | 6 +-- src/rpc/inc/ttcpserver.h | 4 +- src/rpc/inc/tudp.h | 8 +-- src/rpc/src/thaship.c | 12 ++--- src/rpc/src/trpc.c | 20 ++++---- src/rpc/src/ttcpclient.c | 14 +++--- src/rpc/src/ttcpserver.c | 28 +++++------ src/rpc/src/tudp.c | 66 ++++++++++++------------- src/system/detail/inc/mgmt.h | 2 +- src/system/detail/inc/vnodeShell.h | 2 +- src/system/detail/src/mgmtConn.c | 2 +- src/system/detail/src/mgmtProfile.c | 6 +-- src/system/detail/src/mgmtShell.c | 2 +- src/system/detail/src/vnodeShell.c | 2 +- src/util/src/tglobalcfg.c | 16 +++--- src/util/src/tsocket.c | 22 ++++----- 39 files changed, 171 insertions(+), 171 deletions(-) diff --git a/src/client/inc/tscCache.h b/src/client/inc/tscCache.h index 096a6618f6..4c6acec096 100644 --- a/src/client/inc/tscCache.h +++ b/src/client/inc/tscCache.h @@ -24,9 +24,9 @@ void *taosOpenConnCache(int maxSessions, void (*cleanFp)(void *), void *tmrCtrl, void taosCloseConnCache(void *handle); -void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, char *user); +void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, uint16_t port, char *user); -void *taosGetConnFromCache(void *handle, uint32_t ip, short port, char *user); +void *taosGetConnFromCache(void *handle, uint32_t ip, uint16_t port, char *user); #ifdef __cplusplus } diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index e0c073d153..47f25babe0 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -226,7 +226,7 @@ void doAddGroupColumnForSubquery(SSqlCmd* pCmd, int32_t tagIndex); int16_t tscGetJoinTagColIndexByUid(SSqlCmd* pCmd, uint64_t uid); -TAOS* taos_connect_a(char* ip, char* user, char* pass, char* db, int port, void (*fp)(void*, TAOS_RES*, int), +TAOS* taos_connect_a(char* ip, char* user, char* pass, char* db, uint16_t port, void (*fp)(void*, TAOS_RES*, int), void* param, void** taos); void sortRemoveDuplicates(STableDataBlocks* dataBuf); diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 44bfc978a3..7341d674d3 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -342,7 +342,7 @@ typedef struct _tsc_obj { void * signature; void * pTimer; char mgmtIp[TSDB_USER_LEN]; - short mgmtPort; + uint16_t mgmtPort; char user[TSDB_USER_LEN]; char pass[TSDB_KEY_LEN]; char acctId[TSDB_DB_NAME_LEN]; diff --git a/src/client/src/tscCache.c b/src/client/src/tscCache.c index f508857ce1..1ac32d7502 100644 --- a/src/client/src/tscCache.c +++ b/src/client/src/tscCache.c @@ -25,7 +25,7 @@ typedef struct _c_hash_t { uint32_t ip; - short port; + uint16_t port; struct _c_hash_t *prev; struct _c_hash_t *next; void * data; @@ -45,14 +45,14 @@ typedef struct { void *pTimer; } SConnCache; -int taosHashConn(void *handle, uint32_t ip, short port, char *user) { +int taosHashConn(void *handle, uint32_t ip, uint16_t port, char *user) { SConnCache *pObj = (SConnCache *)handle; int hash = 0; // size_t user_len = strlen(user); hash = ip >> 16; hash += (unsigned short)(ip & 0xFFFF); - hash += (unsigned short)port; + hash += port; while (*user != '\0') { hash += *user; user++; @@ -74,7 +74,7 @@ void taosRemoveExpiredNodes(SConnCache *pObj, SConnHash *pNode, int hash, uint64 pNext = pNode->next; pObj->total--; pObj->count[hash]--; - tscTrace("%p ip:0x%x:%d:%d:%p removed, connections in cache:%d", pNode->data, pNode->ip, pNode->port, hash, pNode, + tscTrace("%p ip:0x%x:%hu:%d:%p removed, connections in cache:%d", pNode->data, pNode->ip, pNode->port, hash, pNode, pObj->count[hash]); taosMemPoolFree(pObj->connHashMemPool, (char *)pNode); pNode = pNext; @@ -86,7 +86,7 @@ void taosRemoveExpiredNodes(SConnCache *pObj, SConnHash *pNode, int hash, uint64 pObj->connHashList[hash] = NULL; } -void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, char *user) { +void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, uint16_t port, char *user) { int hash; SConnHash * pNode; SConnCache *pObj; @@ -125,7 +125,7 @@ void *taosAddConnIntoCache(void *handle, void *data, uint32_t ip, short port, ch pthread_mutex_unlock(&pObj->mutex); - tscTrace("%p ip:0x%x:%d:%d:%p added, connections in cache:%d", data, ip, port, hash, pNode, pObj->count[hash]); + tscTrace("%p ip:0x%x:%hu:%d:%p added, connections in cache:%d", data, ip, port, hash, pNode, pObj->count[hash]); return pObj; } @@ -152,7 +152,7 @@ void taosCleanConnCache(void *handle, void *tmrId) { taosTmrReset(taosCleanConnCache, pObj->keepTimer * 2, pObj, pObj->tmrCtrl, &pObj->pTimer); } -void *taosGetConnFromCache(void *handle, uint32_t ip, short port, char *user) { +void *taosGetConnFromCache(void *handle, uint32_t ip, uint16_t port, char *user) { int hash; SConnHash * pNode; SConnCache *pObj; @@ -201,7 +201,7 @@ void *taosGetConnFromCache(void *handle, uint32_t ip, short port, char *user) { pthread_mutex_unlock(&pObj->mutex); if (pData) { - tscTrace("%p ip:0x%x:%d:%d:%p retrieved, connections in cache:%d", pData, ip, port, hash, pNode, pObj->count[hash]); + tscTrace("%p ip:0x%x:%hu:%d:%p retrieved, connections in cache:%d", pData, ip, port, hash, pNode, pObj->count[hash]); } return pData; diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index 350167a3b3..61bc9dd99e 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -23,7 +23,7 @@ void tscSaveSlowQueryFp(void *handle, void *tmrId); void *tscSlowQueryConn = NULL; bool tscSlowQueryConnInitialized = false; -TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, int port, void (*fp)(void *, TAOS_RES *, int), +TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int), void *param, void **taos); void tscInitConnCb(void *param, TAOS_RES *result, int code) { diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index c66d524fee..f5727677c5 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -2669,7 +2669,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { return TSDB_CODE_INVALID_SQL; } - int32_t port = strtol(portStr, NULL, 10); + uint16_t port = (uint16_t)strtol(portStr, NULL, 10); if (port <= 0 || port > 65535) { memset(pCmd->payload, 0, tListLen(pCmd->payload)); diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 6ec8f425ca..13c5669fec 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -28,7 +28,7 @@ #include "ttimer.h" #include "tutil.h" -TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const char *db, int port, void (*fp)(void *, TAOS_RES *, int), +TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int), void *param, void **taos) { STscObj *pObj; @@ -153,7 +153,7 @@ TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const return pObj; } -TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, int port) { +TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) { if (ip == NULL || (ip != NULL && (strcmp("127.0.0.1", ip) == 0 || strcasecmp("localhost", ip) == 0))) { #ifdef CLUSTER ip = tsPrivateIp; @@ -205,7 +205,7 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha return taos; } -TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, int port, void (*fp)(void *, TAOS_RES *, int), +TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int), void *param, void **taos) { #ifndef CLUSTER if (ip == NULL) { diff --git a/src/inc/sdb.h b/src/inc/sdb.h index f645039441..389aecfb7b 100644 --- a/src/inc/sdb.h +++ b/src/inc/sdb.h @@ -23,8 +23,8 @@ extern "C" { #include "taosmsg.h" #include "tsdb.h" -extern short tsMgmtMgmtPort; -extern short tsMgmtSyncPort; +extern uint16_t tsMgmtMgmtPort; +extern uint16_t tsMgmtSyncPort; extern int sdbMaxNodes; extern int tsMgmtPeerHBTimer; // seconds extern char sdbZone[]; diff --git a/src/inc/taos.h b/src/inc/taos.h index 05acc91551..2fd6d8be92 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -59,7 +59,7 @@ typedef struct taosField { void taos_init(); int taos_options(TSDB_OPTION option, const void *arg, ...); -TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, int port); +TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port); void taos_close(TAOS *taos); typedef struct TAOS_BIND { diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index e75404ad98..d02251c212 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -222,7 +222,7 @@ typedef struct { // internal part uint32_t destId; char meterId[TSDB_UNI_LEN]; - short port; // for UDP only + uint16_t port; // for UDP only char empty[1]; char msgType; int32_t msgLen; diff --git a/src/inc/tglobalcfg.h b/src/inc/tglobalcfg.h index 09ced23c91..577f3e8c89 100644 --- a/src/inc/tglobalcfg.h +++ b/src/inc/tglobalcfg.h @@ -57,12 +57,12 @@ extern char scriptDir[]; extern char tsMasterIp[]; extern char tsSecondIp[]; -extern short tsMgmtVnodePort; -extern short tsMgmtShellPort; -extern short tsVnodeShellPort; -extern short tsVnodeVnodePort; -extern short tsMgmtMgmtPort; -extern short tsMgmtSyncPort; +extern uint16_t tsMgmtVnodePort; +extern uint16_t tsMgmtShellPort; +extern uint16_t tsVnodeShellPort; +extern uint16_t tsVnodeVnodePort; +extern uint16_t tsMgmtMgmtPort; +extern uint16_t tsMgmtSyncPort; extern int tsStatusInterval; extern int tsShellActivityTimer; @@ -141,7 +141,7 @@ extern int tsProjectExecInterval; extern int64_t tsMaxRetentWindow; extern char tsHttpIp[]; -extern short tsHttpPort; +extern uint16_t tsHttpPort; extern int tsHttpCacheSessions; extern int tsHttpSessionExpire; extern int tsHttpMaxThreads; diff --git a/src/inc/trpc.h b/src/inc/trpc.h index ef86e672d1..97a0c905f8 100644 --- a/src/inc/trpc.h +++ b/src/inc/trpc.h @@ -47,7 +47,7 @@ extern "C" { typedef struct { char *localIp; // local IP used - short localPort; // local port + uint16_t localPort; // local port char *label; // for debug purpose int numOfThreads; // number of threads to handle connections void *(*fp)(char *, void *, void *); // function to process the incoming msg @@ -72,7 +72,7 @@ typedef struct { void * shandle; // pointer returned by taosOpenRpc void * ahandle; // handle provided by app char * peerIp; // peer IP string - short peerPort; // peer port + uint16_t peerPort; // peer port char spi; // security parameter index char encrypt; // encrypt algorithm char * secret; // key for authentication @@ -107,7 +107,7 @@ int taosSendSimpleRsp(void *thandle, char rsptype, char code); int taosSetSecurityInfo(int cid, int sid, char *id, int spi, int encrypt, char *secret, char *ckey); -void taosGetRpcConnInfo(void *thandle, uint32_t *peerId, uint32_t *peerIp, short *peerPort, int *cid, int *sid); +void taosGetRpcConnInfo(void *thandle, uint32_t *peerId, uint32_t *peerIp, uint16_t *peerPort, int *cid, int *sid); int taosGetOutType(void *thandle); diff --git a/src/inc/tsocket.h b/src/inc/tsocket.h index 0a02fcf551..9eb4c26464 100644 --- a/src/inc/tsocket.h +++ b/src/inc/tsocket.h @@ -33,19 +33,19 @@ int taosWriteMsg(int fd, void *ptr, int nbytes); int taosReadMsg(int fd, void *ptr, int nbytes); -int taosOpenUdpSocket(char *ip, short port); +int taosOpenUdpSocket(char *ip, uint16_t port); -int taosOpenTcpClientSocket(char *ip, short port, char *localIp); +int taosOpenTcpClientSocket(char *ip, uint16_t port, char *localIp); -int taosOpenTcpServerSocket(char *ip, short port); +int taosOpenTcpServerSocket(char *ip, uint16_t port); int taosKeepTcpAlive(int sockFd); void taosCloseTcpSocket(int sockFd); -int taosOpenUDServerSocket(char *ip, short port); +int taosOpenUDServerSocket(char *ip, uint16_t port); -int taosOpenUDClientSocket(char *ip, short port); +int taosOpenUDClientSocket(char *ip, uint16_t port); int taosOpenRawSocket(char *ip); diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 47ed92e2f7..37530e1e8c 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -67,7 +67,7 @@ static struct argp_option options[] = { /* Used by main to communicate with parse_opt. */ struct arguments { char *host; - int port; + uint16_t port; char *user; char *password; char *database; @@ -310,7 +310,7 @@ int main(int argc, char *argv[]) { enum MODE query_mode = arguments.mode; char *ip_addr = arguments.host; - int port = arguments.port; + uint16_t port = arguments.port; char *user = arguments.user; char *pass = arguments.password; char *db_name = arguments.database; @@ -343,7 +343,7 @@ int main(int argc, char *argv[]) { struct tm tm = *localtime(&tTime); fprintf(fp, "###################################################################\n"); - fprintf(fp, "# Server IP: %s:%d\n", ip_addr == NULL ? "localhost" : ip_addr, port); + fprintf(fp, "# Server IP: %s:%hu\n", ip_addr == NULL ? "localhost" : ip_addr, port); fprintf(fp, "# User: %s\n", user); fprintf(fp, "# Password: %s\n", pass); fprintf(fp, "# Use metric: %s\n", use_metric ? "true" : "false"); diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index f168a0d90f..c8ef3bc048 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -172,7 +172,7 @@ struct arguments { char *host; char *user; char *password; - int port; + uint16_t port; // output file char output[TSDB_FILENAME_LEN + 1]; char input[TSDB_FILENAME_LEN + 1]; diff --git a/src/modules/http/inc/httpHandle.h b/src/modules/http/inc/httpHandle.h index e7ac0365c2..72ef9f222a 100644 --- a/src/modules/http/inc/httpHandle.h +++ b/src/modules/http/inc/httpHandle.h @@ -210,7 +210,7 @@ typedef struct HttpThread { typedef struct _http_server_obj_ { char label[HTTP_LABEL_SIZE]; char serverIp[16]; - short serverPort; + uint16_t serverPort; int cacheContext; int sessionExpire; int numOfThreads; @@ -233,7 +233,7 @@ bool httpCheckUsedbSql(char *sql); void httpTimeToString(time_t t, char *buf, int buflen); // http init method -void *httpInitServer(char *ip, short port, char *label, int numOfThreads, void *fp, void *shandle); +void *httpInitServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle); void httpCleanUpServer(HttpServer *pServer); // http server connection diff --git a/src/modules/http/src/httpSql.c b/src/modules/http/src/httpSql.c index 9254658d58..0e3b211abb 100644 --- a/src/modules/http/src/httpSql.c +++ b/src/modules/http/src/httpSql.c @@ -25,7 +25,7 @@ #include "taos.h" #include "tsclient.h" -void *taos_connect_a(char *ip, char *user, char *pass, char *db, int port, void (*fp)(void *, TAOS_RES *, int), +void *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int), void *param, void **taos); void httpProcessMultiSql(HttpContext *pContext); void taosNotePrint(const char * const format, ...); diff --git a/src/modules/monitor/src/monitorSystem.c b/src/modules/monitor/src/monitorSystem.c index 4d6577c8f3..c4b04365d3 100644 --- a/src/modules/monitor/src/monitorSystem.c +++ b/src/modules/monitor/src/monitorSystem.c @@ -61,7 +61,7 @@ typedef struct { MonitorConn *monitor = NULL; -TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, int port, void (*fp)(void *, TAOS_RES *, int), +TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int), void *param, void **taos); void monitorInitConn(void *para, void *unused); void monitorInitConnCb(void *param, TAOS_RES *result, int code); diff --git a/src/os/darwin/src/tdarwin.c b/src/os/darwin/src/tdarwin.c index de37c76edd..133bb4893c 100644 --- a/src/os/darwin/src/tdarwin.c +++ b/src/os/darwin/src/tdarwin.c @@ -170,12 +170,12 @@ int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optle return setsockopt(socketfd, level, optname, optval, (socklen_t)optlen); } -int taosOpenUDClientSocket(char *ip, short port) { +int taosOpenUDClientSocket(char *ip, uint16_t port) { int sockFd = 0; struct sockaddr_un serverAddr; int ret; char name[128]; - sprintf(name, "%s.%d", ip, port); + sprintf(name, "%s.%hu", ip, port); sockFd = socket(AF_UNIX, SOCK_STREAM, 0); @@ -198,13 +198,13 @@ int taosOpenUDClientSocket(char *ip, short port) { return sockFd; } -int taosOpenUDServerSocket(char *ip, short port) { +int taosOpenUDServerSocket(char *ip, uint16_t port) { struct sockaddr_un serverAdd; int sockFd; char name[128]; pTrace("open ud socket:%s", name); - sprintf(name, "%s.%d", ip, port); + sprintf(name, "%s.%hu", ip, port); bzero((char *)&serverAdd, sizeof(serverAdd)); serverAdd.sun_family = AF_UNIX; @@ -295,7 +295,7 @@ void taosGetSystemInfo() { taosGetSystemLocale(); } -void *taosInitTcpClient(char *ip, short port, char *flabel, int num, void *fp, void *shandle) { +void *taosInitTcpClient(char *ip, uint16_t port, char *flabel, int num, void *fp, void *shandle) { tError("function taosInitTcpClient is not implemented in darwin system, exit!"); exit(0); } @@ -305,12 +305,12 @@ void taosCloseTcpClientConnection(void *chandle) { exit(0); } -void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short port) { +void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, uint16_t port) { tError("function taosOpenTcpClientConnection is not implemented in darwin system, exit!"); exit(0); } -int taosSendTcpClientData(unsigned int ip, short port, char *data, int len, void *chandle) { +int taosSendTcpClientData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) { tError("function taosSendTcpClientData is not implemented in darwin system, exit!"); exit(0); } @@ -330,12 +330,12 @@ void taosCleanUpTcpServer(void *handle) { exit(0); } -void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, void *fp, void *shandle) { +void *taosInitTcpServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle) { tError("function taosInitTcpServer is not implemented in darwin system, exit!"); exit(0); } -int taosSendTcpServerData(unsigned int ip, short port, char *data, int len, void *chandle) { +int taosSendTcpServerData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) { tError("function taosSendTcpServerData is not implemented in darwin system, exit!"); exit(0); } diff --git a/src/os/linux/src/tlinux.c b/src/os/linux/src/tlinux.c index 6a7225b476..a166603615 100644 --- a/src/os/linux/src/tlinux.c +++ b/src/os/linux/src/tlinux.c @@ -163,12 +163,12 @@ int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optle return setsockopt(socketfd, level, optname, optval, (socklen_t)optlen); } -int taosOpenUDClientSocket(char *ip, short port) { +int taosOpenUDClientSocket(char *ip, uint16_t port) { int sockFd = 0; struct sockaddr_un serverAddr; int ret; char name[128]; - sprintf(name, "%s.%d", ip, port); + sprintf(name, "%s.%hu", ip, port); sockFd = socket(AF_UNIX, SOCK_STREAM, 0); @@ -191,13 +191,13 @@ int taosOpenUDClientSocket(char *ip, short port) { return sockFd; } -int taosOpenUDServerSocket(char *ip, short port) { +int taosOpenUDServerSocket(char *ip, uint16_t port) { struct sockaddr_un serverAdd; int sockFd; char name[128]; pTrace("open ud socket:%s", name); - sprintf(name, "%s.%d", ip, port); + sprintf(name, "%s.%hu", ip, port); bzero((char *)&serverAdd, sizeof(serverAdd)); serverAdd.sun_family = AF_UNIX; diff --git a/src/os/windows/src/twintcpclient.c b/src/os/windows/src/twintcpclient.c index 17293c3915..9f40dae434 100644 --- a/src/os/windows/src/twintcpclient.c +++ b/src/os/windows/src/twintcpclient.c @@ -15,7 +15,7 @@ #include "tlog.h" -void *taosInitTcpClient(char *ip, short port, char *label, int num, void *fp, void *shandle) { +void *taosInitTcpClient(char *ip, uint16_t port, char *label, int num, void *fp, void *shandle) { tError("InitTcpClient not support in windows"); return 0; } @@ -24,12 +24,12 @@ void taosCloseTcpClientConnection(void *chandle) { tError("CloseTcpClientConnection not support in windows"); } -void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short port) { +void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, uint16_t port) { tError("OpenTcpClientConnection not support in windows"); return 0; } -int taosSendTcpClientData(unsigned int ip, short port, char *data, int len, void *chandle) { +int taosSendTcpClientData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) { tError("SendTcpClientData not support in windows"); return 0; } diff --git a/src/os/windows/src/twintcpserver.c b/src/os/windows/src/twintcpserver.c index a51d807aa2..d5e25693d0 100644 --- a/src/os/windows/src/twintcpserver.c +++ b/src/os/windows/src/twintcpserver.c @@ -23,12 +23,12 @@ void taosCleanUpTcpServer(void *handle) { tError("CleanUpTcpServer not support in windows"); } -void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, void *fp, void *shandle) { +void *taosInitTcpServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle) { tError("InitTcpServer not support in windows"); return 0; } -int taosSendTcpServerData(unsigned int ip, short port, char *data, int len, void *chandle) { +int taosSendTcpServerData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) { tError("SendTcpServerData not support in windows"); return 0; } diff --git a/src/rpc/inc/thaship.h b/src/rpc/inc/thaship.h index 262673af62..4acf8b3fbb 100644 --- a/src/rpc/inc/thaship.h +++ b/src/rpc/inc/thaship.h @@ -18,8 +18,8 @@ void *taosOpenIpHash(int maxSessions); void taosCloseIpHash(void *handle); -void *taosAddIpHash(void *handle, void *pData, uint32_t ip, short port); -void taosDeleteIpHash(void *handle, uint32_t ip, short port); -void *taosGetIpHash(void *handle, uint32_t ip, short port); +void *taosAddIpHash(void *handle, void *pData, uint32_t ip, uint16_t port); +void taosDeleteIpHash(void *handle, uint32_t ip, uint16_t port); +void *taosGetIpHash(void *handle, uint32_t ip, uint16_t port); #endif diff --git a/src/rpc/inc/ttcpclient.h b/src/rpc/inc/ttcpclient.h index 8c2131f1f6..8427c6f162 100644 --- a/src/rpc/inc/ttcpclient.h +++ b/src/rpc/inc/ttcpclient.h @@ -18,10 +18,10 @@ #include "tsdb.h" -void *taosInitTcpClient(char *ip, short port, char *label, int num, void *fp, void *shandle); +void *taosInitTcpClient(char *ip, uint16_t port, char *label, int num, void *fp, void *shandle); void taosCleanUpTcpClient(void *chandle); -void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short port); +void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, uint16_t port); void taosCloseTcpClientConnection(void *chandle); -int taosSendTcpClientData(uint32_t ip, short port, char *data, int len, void *chandle); +int taosSendTcpClientData(uint32_t ip, uint16_t port, char *data, int len, void *chandle); #endif diff --git a/src/rpc/inc/ttcpserver.h b/src/rpc/inc/ttcpserver.h index 3e3feb4691..ba3bd25719 100644 --- a/src/rpc/inc/ttcpserver.h +++ b/src/rpc/inc/ttcpserver.h @@ -18,9 +18,9 @@ #include "tsdb.h" -void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, void *fp, void *shandle); +void *taosInitTcpServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle); void taosCleanUpTcpServer(void *param); void taosCloseTcpServerConnection(void *param); -int taosSendTcpServerData(uint32_t ip, short port, char *data, int len, void *chandle); +int taosSendTcpServerData(uint32_t ip, uint16_t port, char *data, int len, void *chandle); #endif diff --git a/src/rpc/inc/tudp.h b/src/rpc/inc/tudp.h index c90e21f510..27c7593090 100644 --- a/src/rpc/inc/tudp.h +++ b/src/rpc/inc/tudp.h @@ -18,11 +18,11 @@ #include "tsdb.h" -void *taosInitUdpServer(char *ip, short port, char *label, int, void *fp, void *shandle); -void *taosInitUdpClient(char *ip, short port, char *label, int, void *fp, void *shandle); +void *taosInitUdpServer(char *ip, uint16_t port, char *label, int, void *fp, void *shandle); +void *taosInitUdpClient(char *ip, uint16_t port, char *label, int, void *fp, void *shandle); void taosCleanUpUdpConnection(void *handle); -int taosSendUdpData(uint32_t ip, short port, char *data, int dataLen, void *chandle); -void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, short port); +int taosSendUdpData(uint32_t ip, uint16_t port, char *data, int dataLen, void *chandle); +void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, uint16_t port); void taosFreeMsgHdr(void *hdr); int taosMsgHdrSize(void *hdr); diff --git a/src/rpc/src/thaship.c b/src/rpc/src/thaship.c index 2c46e53258..6b76c4b59e 100644 --- a/src/rpc/src/thaship.c +++ b/src/rpc/src/thaship.c @@ -19,7 +19,7 @@ typedef struct _ip_hash_t { uint32_t ip; - short port; + uint16_t port; int hash; struct _ip_hash_t *prev; struct _ip_hash_t *next; @@ -32,20 +32,20 @@ typedef struct { int maxSessions; } SHashObj; -int taosHashIp(void *handle, uint32_t ip, short port) { +int taosHashIp(void *handle, uint32_t ip, uint16_t port) { SHashObj *pObj = (SHashObj *)handle; int hash = 0; hash = (int)(ip >> 16); hash += (unsigned short)(ip & 0xFFFF); - hash += (unsigned short)port; + hash += port; hash = hash % pObj->maxSessions; return hash; } -void *taosAddIpHash(void *handle, void *data, uint32_t ip, short port) { +void *taosAddIpHash(void *handle, void *data, uint32_t ip, uint16_t port) { int hash; SIpHash * pNode; SHashObj *pObj; @@ -68,7 +68,7 @@ void *taosAddIpHash(void *handle, void *data, uint32_t ip, short port) { return pObj; } -void taosDeleteIpHash(void *handle, uint32_t ip, short port) { +void taosDeleteIpHash(void *handle, uint32_t ip, uint16_t port) { int hash; SIpHash * pNode; SHashObj *pObj; @@ -100,7 +100,7 @@ void taosDeleteIpHash(void *handle, uint32_t ip, short port) { } } -void *taosGetIpHash(void *handle, uint32_t ip, short port) { +void *taosGetIpHash(void *handle, uint32_t ip, uint16_t port) { int hash; SIpHash * pNode; SHashObj *pObj; diff --git a/src/rpc/src/trpc.c b/src/rpc/src/trpc.c index 3aa50cf168..643622dfa7 100644 --- a/src/rpc/src/trpc.c +++ b/src/rpc/src/trpc.c @@ -51,10 +51,10 @@ typedef struct { uint8_t secret[TSDB_KEY_LEN]; uint8_t ckey[TSDB_KEY_LEN]; - short localPort; // for UDP only + uint16_t localPort; // for UDP only uint32_t peerUid; uint32_t peerIp; // peer IP - short peerPort; // peer port + uint16_t peerPort; // peer port char peerIpstr[20]; // peer IP string uint16_t tranId; // outgoing transcation ID, for build message uint16_t outTranId; // outgoing transcation ID @@ -99,7 +99,7 @@ typedef struct rpc_server { int idleTime; // milliseconds; int noFree; // do not free the request msg when rsp is received int index; // for UDP server, next thread for new connection - short localPort; + uint16_t localPort; char label[12]; void *(*fp)(char *, void *ahandle, void *thandle); void (*efp)(int); // FP to report error @@ -114,16 +114,16 @@ int tsRpcProgressTime = 10; // milliseocnds int tsRpcMaxRetry; int tsRpcHeadSize; -void *(*taosInitConn[])(char *ip, short port, char *label, int threads, void *fp, void *shandle) = { +void *(*taosInitConn[])(char *ip, uint16_t port, char *label, int threads, void *fp, void *shandle) = { taosInitUdpServer, taosInitUdpClient, taosInitTcpServer, taosInitTcpClient}; void (*taosCleanUpConn[])(void *thandle) = {taosCleanUpUdpConnection, taosCleanUpUdpConnection, taosCleanUpTcpServer, taosCleanUpTcpClient}; -int (*taosSendData[])(uint32_t ip, short port, char *data, int len, void *chandle) = { +int (*taosSendData[])(uint32_t ip, uint16_t port, char *data, int len, void *chandle) = { taosSendUdpData, taosSendUdpData, taosSendTcpServerData, taosSendTcpClientData}; -void *(*taosOpenConn[])(void *shandle, void *thandle, char *ip, short port) = { +void *(*taosOpenConn[])(void *shandle, void *thandle, char *ip, uint16_t port) = { taosOpenUdpConnection, taosOpenUdpConnection, NULL, @@ -134,7 +134,7 @@ void (*taosCloseConn[])(void *chandle) = {NULL, NULL, taosCloseTcpServerConnecti int taosReSendRspToPeer(SRpcConn *pConn); void taosProcessTaosTimer(void *, void *); -void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, short port, void *shandle, void *thandle, +void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, uint16_t port, void *shandle, void *thandle, void *chandle); int taosSendDataToPeer(SRpcConn *pConn, char *data, int dataLen); void taosProcessSchedMsg(SSchedMsg *pMsg); @@ -720,7 +720,7 @@ void taosProcessResponse(SRpcConn *pConn) { } int taosProcessMsgHeader(STaosHeader *pHeader, SRpcConn **ppConn, STaosRpc *pServer, int dataLen, uint32_t ip, - short port, void *chandle) { + uint16_t port, void *chandle) { int chann, sid, code = 0; SRpcConn * pConn = NULL; SRpcChann *pChann; @@ -1009,7 +1009,7 @@ void taosProcessIdleTimer(void *param, void *tmrId) { pthread_mutex_unlock(&pChann->mutex); } -void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, short port, void *shandle, void *thandle, +void *taosProcessDataFromPeer(char *data, int dataLen, uint32_t ip, uint16_t port, void *shandle, void *thandle, void *chandle) { STaosHeader *pHeader; uint8_t code; @@ -1312,7 +1312,7 @@ void taosProcessTaosTimer(void *param, void *tmrId) { } -void taosGetRpcConnInfo(void *thandle, uint32_t *peerId, uint32_t *peerIp, short *peerPort, int *cid, int *sid) { +void taosGetRpcConnInfo(void *thandle, uint32_t *peerId, uint32_t *peerIp, uint16_t *peerPort, int *cid, int *sid) { SRpcConn *pConn = (SRpcConn *)thandle; *peerId = pConn->peerId; diff --git a/src/rpc/src/ttcpclient.c b/src/rpc/src/ttcpclient.c index 8e6f91a661..3d39be92fe 100644 --- a/src/rpc/src/ttcpclient.c +++ b/src/rpc/src/ttcpclient.c @@ -30,7 +30,7 @@ typedef struct _tcp_fd { void * thandle; uint32_t ip; char ipstr[20]; - short port; + uint16_t port; struct _tcp_client *pTcp; struct _tcp_fd * prev, *next; } STcpFd; @@ -45,7 +45,7 @@ typedef struct _tcp_client { char label[12]; char ipstr[20]; void * shandle; // handle passed by upper layer during server initialization - void *(*processData)(char *data, int dataLen, unsigned int ip, short port, void *shandle, void *thandle, + void *(*processData)(char *data, int dataLen, unsigned int ip, uint16_t port, void *shandle, void *thandle, void *chandle); // char buffer[128000]; } STcpClient; @@ -194,7 +194,7 @@ static void *taosReadTcpData(void *param) { return NULL; } -void *taosInitTcpClient(char *ip, short port, char *label, int num, void *fp, void *shandle) { +void *taosInitTcpClient(char *ip, uint16_t port, char *label, int num, void *fp, void *shandle) { STcpClient * pTcp; pthread_attr_t thattr; @@ -229,7 +229,7 @@ void *taosInitTcpClient(char *ip, short port, char *label, int num, void *fp, vo return NULL; } - tTrace("%s TCP client is initialized, ip:%s port:%u", label, ip, port); + tTrace("%s TCP client is initialized, ip:%s port:%hu", label, ip, port); return pTcp; } @@ -242,7 +242,7 @@ void taosCloseTcpClientConnection(void *chandle) { taosCleanUpTcpFdObj(pFdObj); } -void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short port) { +void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, uint16_t port) { STcpClient * pTcp = (STcpClient *)shandle; STcpFd * pFdObj; struct epoll_event event; @@ -301,12 +301,12 @@ void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, short pthread_mutex_unlock(&(pTcp->mutex)); - tTrace("%s TCP connection to ip:%s port:%u is created, numOfFds:%d", pTcp->label, ip, port, pTcp->numOfFds); + tTrace("%s TCP connection to ip:%s port:%hu is created, numOfFds:%d", pTcp->label, ip, port, pTcp->numOfFds); return pFdObj; } -int taosSendTcpClientData(uint32_t ip, short port, char *data, int len, void *chandle) { +int taosSendTcpClientData(uint32_t ip, uint16_t port, char *data, int len, void *chandle) { STcpFd *pFdObj = (STcpFd *)chandle; if (chandle == NULL) return -1; diff --git a/src/rpc/src/ttcpserver.c b/src/rpc/src/ttcpserver.c index fee506256b..29ada20bc4 100644 --- a/src/rpc/src/ttcpserver.c +++ b/src/rpc/src/ttcpserver.c @@ -32,7 +32,7 @@ typedef struct _fd_obj { void * thandle; // handle from upper layer, like TAOS char ipstr[TAOS_IPv4ADDR_LEN]; unsigned int ip; - unsigned short port; + uint16_t port; struct _thread_obj *pThreadObj; struct _fd_obj * prev, *next; } SFdObj; @@ -48,13 +48,13 @@ typedef struct _thread_obj { char label[12]; // char buffer[128000]; // buffer to receive data void *shandle; // handle passed by upper layer during server initialization - void *(*processData)(char *data, int dataLen, unsigned int ip, short port, void *shandle, void *thandle, + void *(*processData)(char *data, int dataLen, unsigned int ip, uint16_t port, void *shandle, void *thandle, void *chandle); } SThreadObj; typedef struct { char ip[40]; - short port; + uint16_t port; char label[12]; int numOfThreads; void * shandle; @@ -209,7 +209,7 @@ static void taosProcessTcpData(void *param) { continue; } - pFdObj->thandle = (*(pThreadObj->processData))(buffer, dataLen, pFdObj->ip, (int16_t)pFdObj->port, + pFdObj->thandle = (*(pThreadObj->processData))(buffer, dataLen, pFdObj->ip, pFdObj->port, pThreadObj->shandle, pFdObj->thandle, pFdObj); if (pFdObj->thandle == NULL) taosCleanUpFdObj(pFdObj); @@ -232,10 +232,10 @@ void taosAcceptTcpConnection(void *arg) { sockFd = taosOpenTcpServerSocket(pServerObj->ip, pServerObj->port); if (sockFd < 0) { - tError("%s failed to open TCP socket, ip:%s, port:%u", pServerObj->label, pServerObj->ip, pServerObj->port); + tError("%s failed to open TCP socket, ip:%s, port:%hu", pServerObj->label, pServerObj->ip, pServerObj->port); return; } else { - tTrace("%s TCP server is ready, ip:%s, port:%u", pServerObj->label, pServerObj->ip, pServerObj->port); + tTrace("%s TCP server is ready, ip:%s, port:%hu", pServerObj->label, pServerObj->ip, pServerObj->port); } while (1) { @@ -247,7 +247,7 @@ void taosAcceptTcpConnection(void *arg) { continue; } - tTrace("%s TCP connection from ip:%s port:%u", pServerObj->label, inet_ntoa(clientAddr.sin_addr), + tTrace("%s TCP connection from ip:%s port:%hu", pServerObj->label, inet_ntoa(clientAddr.sin_addr), htons(clientAddr.sin_port)); taosKeepTcpAlive(connFd); @@ -292,7 +292,7 @@ void taosAcceptTcpConnection(void *arg) { pthread_mutex_unlock(&(pThreadObj->threadMutex)); - tTrace("%s TCP thread:%d, a new connection, ip:%s port:%u, numOfFds:%d", pServerObj->label, pThreadObj->threadId, + tTrace("%s TCP thread:%d, a new connection, ip:%s port:%hu, numOfFds:%d", pServerObj->label, pThreadObj->threadId, pFdObj->ipstr, pFdObj->port, pThreadObj->numOfFds); // pick up next thread for next connection @@ -314,10 +314,10 @@ void taosAcceptUDConnection(void *arg) { sockFd = taosOpenUDServerSocket(pServerObj->ip, pServerObj->port); if (sockFd < 0) { - tError("%s failed to open UD socket, ip:%s, port:%u", pServerObj->label, pServerObj->ip, pServerObj->port); + tError("%s failed to open UD socket, ip:%s, port:%hu", pServerObj->label, pServerObj->ip, pServerObj->port); return; } else { - tTrace("%s UD server is ready, ip:%s, port:%u", pServerObj->label, pServerObj->ip, pServerObj->port); + tTrace("%s UD server is ready, ip:%s, port:%hu", pServerObj->label, pServerObj->ip, pServerObj->port); } while (1) { @@ -374,7 +374,7 @@ void taosAcceptUDConnection(void *arg) { } } -void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, void *fp, void *shandle) { +void *taosInitTcpServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle) { int i; SServerObj * pServerObj; pthread_attr_t thattr; @@ -442,7 +442,7 @@ void *taosInitTcpServer(char *ip, short port, char *label, int numOfThreads, voi } */ pthread_attr_destroy(&thattr); - tTrace("%s TCP server is initialized, ip:%s port:%u numOfThreads:%d", label, ip, port, numOfThreads); + tTrace("%s TCP server is initialized, ip:%s port:%hu numOfThreads:%d", label, ip, port, numOfThreads); return (void *)pServerObj; } @@ -468,7 +468,7 @@ void taosListTcpConnection(void *handle, char *buffer) { msg = msg + strlen(msg); pFdObj = pThreadObj->pHead; while (pFdObj) { - sprintf(" ip:%s port:%u\n", pFdObj->ipstr, pFdObj->port); + sprintf(" ip:%s port:%hu\n", pFdObj->ipstr, pFdObj->port); msg = msg + strlen(msg); numOfFds++; numOfConns++; @@ -487,7 +487,7 @@ void taosListTcpConnection(void *handle, char *buffer) { return; } -int taosSendTcpServerData(uint32_t ip, short port, char *data, int len, void *chandle) { +int taosSendTcpServerData(uint32_t ip, uint16_t port, char *data, int len, void *chandle) { SFdObj *pFdObj = (SFdObj *)chandle; if (chandle == NULL) return -1; diff --git a/src/rpc/src/tudp.c b/src/rpc/src/tudp.c index 7a4961f90c..43fee4c089 100644 --- a/src/rpc/src/tudp.c +++ b/src/rpc/src/tudp.c @@ -35,8 +35,8 @@ typedef struct { void * signature; int index; int fd; - short port; // peer port - short localPort; // local port + uint16_t port; // peer port + uint16_t localPort; // local port char label[12]; // copy from udpConnSet; pthread_t thread; pthread_mutex_t mutex; @@ -44,7 +44,7 @@ typedef struct { void * hash; void * shandle; // handle passed by upper layer during server initialization void * pSet; - void *(*processData)(char *data, int dataLen, unsigned int ip, short port, void *shandle, void *thandle, + void *(*processData)(char *data, int dataLen, unsigned int ip, uint16_t port, void *shandle, void *thandle, void *chandle); char buffer[RPC_MAX_UDP_SIZE]; // buffer to receive data } SUdpConn; @@ -53,21 +53,21 @@ typedef struct { int index; int server; char ip[16]; // local IP - short port; // local Port + uint16_t port; // local Port void * shandle; // handle passed by upper layer during server initialization int threads; char label[12]; void * tmrCtrl; pthread_t tcpThread; int tcpFd; - void *(*fp)(char *data, int dataLen, uint32_t ip, short port, void *shandle, void *thandle, void *chandle); + void *(*fp)(char *data, int dataLen, uint32_t ip, uint16_t port, void *shandle, void *thandle, void *chandle); SUdpConn udpConn[]; } SUdpConnSet; typedef struct { void * signature; uint32_t ip; // dest IP - short port; // dest Port + uint16_t port; // dest Port SUdpConn * pConn; struct sockaddr_in destAdd; void * msgHdr; @@ -144,12 +144,12 @@ void *taosReadTcpData(void *argv) { pInfo->msgLen = (int32_t)htonl((uint32_t)pInfo->msgLen); tinet_ntoa(ipstr, pMonitor->ip); - tTrace("%s receive packet via TCP:%s:%d, msgLen:%d, handle:0x%x, source:0x%08x dest:0x%08x tranId:%d", pSet->label, + tTrace("%s receive packet via TCP:%s:%hu, msgLen:%d, handle:0x%x, source:0x%08x dest:0x%08x tranId:%d", pSet->label, ipstr, pInfo->port, pInfo->msgLen, pInfo->handle, pHead->sourceId, pHead->destId, pHead->tranId); fd = taosOpenTcpClientSocket(ipstr, (int16_t)pInfo->port, tsLocalIp); if (fd < 0) { - tError("%s failed to open TCP client socket ip:%s:%d", pSet->label, ipstr, pInfo->port); + tError("%s failed to open TCP client socket ip:%s:%hu", pSet->label, ipstr, pInfo->port); pMonitor->pSet = NULL; return NULL; } @@ -180,7 +180,7 @@ void *taosReadTcpData(void *argv) { tError("%s failed to read data from server, msgLen:%d retLen:%d", pSet->label, pInfo->msgLen, retLen); tfree(buffer); } else { - (*pSet->fp)(buffer, pInfo->msgLen, pMonitor->ip, (int16_t)pInfo->port, pSet->shandle, NULL, pMonitor->pConn); + (*pSet->fp)(buffer, pInfo->msgLen, pMonitor->ip, pInfo->port, pSet->shandle, NULL, pMonitor->pConn); } } @@ -224,7 +224,7 @@ void *taosRecvUdpData(void *param) { struct sockaddr_in sourceAdd; unsigned int addLen, dataLen; SUdpConn * pConn = (SUdpConn *)param; - short port; + uint16_t port; int minSize = sizeof(STaosHeader); memset(&sourceAdd, 0, sizeof(sourceAdd)); @@ -242,7 +242,7 @@ void *taosRecvUdpData(void *param) { continue; } - port = (int16_t)ntohs(sourceAdd.sin_port); + port = ntohs(sourceAdd.sin_port); int processedLen = 0, leftLen = 0; int msgLen = 0; @@ -307,7 +307,7 @@ void *taosTransferDataViaTcp(void *argv) { if (handle == 0) { // receive a packet from client - tTrace("%s data will be received via TCP from 0x%x:%d", pSet->label, pTransfer->ip, pTransfer->port); + tTrace("%s data will be received via TCP from 0x%x:%hu", pSet->label, pTransfer->ip, pTransfer->port); retLen = taosReadMsg(connFd, &head, sizeof(STaosHeader)); if (retLen != (int)sizeof(STaosHeader)) { tError("%s failed to read msg header, retLen:%d", pSet->label, retLen); @@ -345,7 +345,7 @@ void *taosTransferDataViaTcp(void *argv) { tError("%s failed to read data from client, leftLen:%d retLen:%d, error:%s", pSet->label, leftLen, retLen, strerror(errno)); } else { - tTrace("%s data is received from client via TCP from 0x%x:%d, msgLen:%d", pSet->label, pTransfer->ip, + tTrace("%s data is received from client via TCP from 0x%x:%hu, msgLen:%d", pSet->label, pTransfer->ip, pTransfer->port, msgLen); pSet->index = (pSet->index + 1) % pSet->threads; SUdpConn *pConn = pSet->udpConn + pSet->index; @@ -388,7 +388,7 @@ void *taosTransferDataViaTcp(void *argv) { if (retLen != msgLen) { tError("%s failed to send data to client, msgLen:%d retLen:%d", pSet->label, msgLen, retLen); } else { - tTrace("%s data is sent to client successfully via TCP to 0x%x:%d, size:%d", pSet->label, pTransfer->ip, + tTrace("%s data is sent to client successfully via TCP to 0x%x:%hu, size:%d", pSet->label, pTransfer->ip, pTransfer->port, msgLen); } } @@ -413,13 +413,13 @@ void *taosUdpTcpConnection(void *argv) { pSet->tcpFd = taosOpenTcpServerSocket(pSet->ip, pSet->port); if (pSet->tcpFd < 0) { - tPrint("%s failed to create TCP socket %s:%d for UDP server, reason:%s", pSet->label, pSet->ip, pSet->port, + tPrint("%s failed to create TCP socket %s:%hu for UDP server, reason:%s", pSet->label, pSet->ip, pSet->port, strerror(errno)); taosKillSystem(); return NULL; } - tTrace("%s UDP server is created, ip:%s:%d", pSet->label, pSet->ip, pSet->port); + tTrace("%s UDP server is created, ip:%s:%hu", pSet->label, pSet->ip, pSet->port); pthread_attr_init(&thattr); pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_DETACHED); @@ -455,7 +455,7 @@ void *taosUdpTcpConnection(void *argv) { return NULL; } -void *taosInitUdpConnection(char *ip, short port, char *label, int threads, void *fp, void *shandle) { +void *taosInitUdpConnection(char *ip, uint16_t port, char *label, int threads, void *fp, void *shandle) { pthread_attr_t thAttr; SUdpConn * pConn; SUdpConnSet * pSet; @@ -488,13 +488,13 @@ void *taosInitUdpConnection(char *ip, short port, char *label, int threads, void pthread_attr_init(&thAttr); pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE); - short ownPort; + uint16_t ownPort; for (int i = 0; i < threads; ++i) { pConn = pSet->udpConn + i; - ownPort = (int16_t)(port ? port + i : 0); + ownPort = (port ? port + i : 0); pConn->fd = taosOpenUdpSocket(ip, ownPort); if (pConn->fd < 0) { - tError("%s failed to open UDP socket %s:%d", label, ip, port); + tError("%s failed to open UDP socket %s:%hu", label, ip, port); taosCleanUpUdpConnection(pSet); return NULL; } @@ -528,12 +528,12 @@ void *taosInitUdpConnection(char *ip, short port, char *label, int threads, void } pthread_attr_destroy(&thAttr); - tTrace("%s UDP connection is initialized, ip:%s port:%u threads:%d", label, ip, port, threads); + tTrace("%s UDP connection is initialized, ip:%s port:%hu threads:%d", label, ip, port, threads); return pSet; } -void *taosInitUdpServer(char *ip, short port, char *label, int threads, void *fp, void *shandle) { +void *taosInitUdpServer(char *ip, uint16_t port, char *label, int threads, void *fp, void *shandle) { SUdpConnSet *pSet; pSet = taosInitUdpConnection(ip, port, label, threads, fp, shandle); if (pSet == NULL) return NULL; @@ -554,7 +554,7 @@ void *taosInitUdpServer(char *ip, short port, char *label, int threads, void *fp return pSet; } -void *taosInitUdpClient(char *ip, short port, char *label, int threads, void *fp, void *shandle) { +void *taosInitUdpClient(char *ip, uint16_t port, char *label, int threads, void *fp, void *shandle) { return taosInitUdpConnection(ip, port, label, threads, fp, shandle); } @@ -590,7 +590,7 @@ void taosCleanUpUdpConnection(void *handle) { tfree(pSet); } -void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, short port) { +void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, uint16_t port) { SUdpConnSet *pSet = (SUdpConnSet *)shandle; pSet->index = (pSet->index + 1) % pSet->threads; @@ -598,7 +598,7 @@ void *taosOpenUdpConnection(void *shandle, void *thandle, char *ip, short port) SUdpConn *pConn = pSet->udpConn + pSet->index; pConn->port = port; - tTrace("%s UDP connection is setup, ip: %s:%d, local: %s:%d", pConn->label, ip, port, pSet->ip, + tTrace("%s UDP connection is setup, ip: %s:%hu, local: %s:%d", pConn->label, ip, port, pSet->ip, ntohs((uint16_t)pConn->localPort)); return pConn; @@ -642,7 +642,7 @@ void taosProcessUdpBufTimer(void *param, void *tmrId) { if (pBuf) taosTmrReset(taosProcessUdpBufTimer, RPC_UDP_BUF_TIME, pBuf, pConn->tmrCtrl, &pBuf->timer); } -SUdpBuf *taosCreateUdpBuf(SUdpConn *pConn, uint32_t ip, short port) { +SUdpBuf *taosCreateUdpBuf(SUdpConn *pConn, uint32_t ip, uint16_t port) { SUdpBuf *pBuf = (SUdpBuf *)malloc(sizeof(SUdpBuf)); memset(pBuf, 0, sizeof(SUdpBuf)); @@ -652,7 +652,7 @@ SUdpBuf *taosCreateUdpBuf(SUdpConn *pConn, uint32_t ip, short port) { pBuf->destAdd.sin_family = AF_INET; pBuf->destAdd.sin_addr.s_addr = ip; - pBuf->destAdd.sin_port = (uint16_t)htons((uint16_t)port); + pBuf->destAdd.sin_port = (uint16_t)htons(port); taosInitMsgHdr(&(pBuf->msgHdr), &(pBuf->destAdd), RPC_MAX_UDP_PKTS); pBuf->signature = pBuf; taosTmrReset(taosProcessUdpBufTimer, RPC_UDP_BUF_TIME, pBuf, pConn->tmrCtrl, &pBuf->timer); @@ -663,7 +663,7 @@ SUdpBuf *taosCreateUdpBuf(SUdpConn *pConn, uint32_t ip, short port) { return pBuf; } -int taosSendPacketViaTcp(uint32_t ip, short port, char *data, int dataLen, void *chandle) { +int taosSendPacketViaTcp(uint32_t ip, uint16_t port, char *data, int dataLen, void *chandle) { SUdpConn * pConn = (SUdpConn *)chandle; SUdpConnSet *pSet = (SUdpConnSet *)pConn->pSet; int code = -1, retLen, msgLen; @@ -680,13 +680,13 @@ int taosSendPacketViaTcp(uint32_t ip, short port, char *data, int dataLen, void SPacketInfo *pInfo = (SPacketInfo *)pHead->content; pInfo->handle = (uint64_t)data; - pInfo->port = (uint16_t)pSet->port; + pInfo->port = pSet->port; pInfo->msgLen = pHead->msgLen; msgLen = sizeof(STaosHeader) + sizeof(SPacketInfo); pHead->msgLen = (int32_t)htonl((uint32_t)msgLen); code = taosSendUdpData(ip, port, buffer, msgLen, chandle); - tTrace("%s data from server will be sent via TCP:%d, msgType:%d, length:%d, handle:0x%x", pSet->label, pInfo->port, + tTrace("%s data from server will be sent via TCP:%hu, msgType:%d, length:%d, handle:0x%x", pSet->label, pInfo->port, pHead->msgType, htonl((uint32_t)pInfo->msgLen), pInfo->handle); if (code > 0) code = dataLen; } else { @@ -706,7 +706,7 @@ int taosSendPacketViaTcp(uint32_t ip, short port, char *data, int dataLen, void tinet_ntoa(ipstr, ip); int fd = taosOpenTcpClientSocket(ipstr, pConn->port, tsLocalIp); if (fd < 0) { - tError("%s failed to open TCP socket to:%s:%u to send packet", pSet->label, ipstr, pConn->port); + tError("%s failed to open TCP socket to:%s:%hu to send packet", pSet->label, ipstr, pConn->port); } else { SHandleViaTcp handleViaTcp; taosInitHandleViaTcp(&handleViaTcp, 0); @@ -734,7 +734,7 @@ int taosSendPacketViaTcp(uint32_t ip, short port, char *data, int dataLen, void return code; } -int taosSendUdpData(uint32_t ip, short port, char *data, int dataLen, void *chandle) { +int taosSendUdpData(uint32_t ip, uint16_t port, char *data, int dataLen, void *chandle) { SUdpConn *pConn = (SUdpConn *)chandle; SUdpBuf * pBuf; @@ -747,7 +747,7 @@ int taosSendUdpData(uint32_t ip, short port, char *data, int dataLen, void *chan memset(&destAdd, 0, sizeof(destAdd)); destAdd.sin_family = AF_INET; destAdd.sin_addr.s_addr = ip; - destAdd.sin_port = htons((uint16_t)port); + destAdd.sin_port = htons(port); int ret = (int)sendto(pConn->fd, data, (size_t)dataLen, 0, (struct sockaddr *)&destAdd, sizeof(destAdd)); tTrace("%s msg is sent to 0x%x:%hu len:%d ret:%d localPort:%hu chandle:0x%x", pConn->label, destAdd.sin_addr.s_addr, diff --git a/src/system/detail/inc/mgmt.h b/src/system/detail/inc/mgmt.h index 702eb00875..7cdc36a446 100644 --- a/src/system/detail/inc/mgmt.h +++ b/src/system/detail/inc/mgmt.h @@ -233,7 +233,7 @@ typedef struct _connObj { uint32_t queryId; // query ID to be killed uint32_t streamId; // stream ID to be killed uint32_t ip; // shell IP - short port; // shell port + uint16_t port; // shell port void * thandle; SQList * pQList; // query list SSList * pSList; // stream list diff --git a/src/system/detail/inc/vnodeShell.h b/src/system/detail/inc/vnodeShell.h index e450983dd7..25646fbb1a 100644 --- a/src/system/detail/inc/vnodeShell.h +++ b/src/system/detail/inc/vnodeShell.h @@ -26,7 +26,7 @@ typedef struct { int sid; int vnode; uint32_t ip; - short port; + uint16_t port; int count; // track the number of imports int code; // track the code of imports int numOfTotalPoints; // track the total number of points imported diff --git a/src/system/detail/src/mgmtConn.c b/src/system/detail/src/mgmtConn.c index 40385d2fc4..13275300a6 100644 --- a/src/system/detail/src/mgmtConn.c +++ b/src/system/detail/src/mgmtConn.c @@ -25,7 +25,7 @@ typedef struct { char user[TSDB_METER_ID_LEN]; uint64_t stime; uint32_t ip; - short port; + uint16_t port; } SConnInfo; typedef struct { diff --git a/src/system/detail/src/mgmtProfile.c b/src/system/detail/src/mgmtProfile.c index bd5540e5ee..e7dbeaaa25 100644 --- a/src/system/detail/src/mgmtProfile.c +++ b/src/system/detail/src/mgmtProfile.c @@ -23,7 +23,7 @@ typedef struct { uint32_t ip; - short port; + uint16_t port; char user[TSDB_METER_ID_LEN]; } SCDesc; @@ -180,7 +180,7 @@ int mgmtKillQuery(char *qidstr, SConnObj *pConn) { chr = strchr(temp, ':'); if (chr == NULL) goto _error; *chr = 0; - short port = htons(atoi(temp)); + uint16_t port = htons(atoi(temp)); temp = chr + 1; uint32_t queryId = atoi(temp); @@ -448,7 +448,7 @@ int mgmtKillStream(char *qidstr, SConnObj *pConn) { chr = strchr(temp, ':'); if (chr == NULL) goto _error; *chr = 0; - short port = htons(atoi(temp)); + uint16_t port = htons(atoi(temp)); temp = chr + 1; uint32_t streamId = atoi(temp); diff --git a/src/system/detail/src/mgmtShell.c b/src/system/detail/src/mgmtShell.c index e58938bdad..450527d009 100644 --- a/src/system/detail/src/mgmtShell.c +++ b/src/system/detail/src/mgmtShell.c @@ -1276,7 +1276,7 @@ void *mgmtProcessMsgFromShell(char *msg, void *ahandle, void *thandle) { if (pConn->pUser) { pConn->pAcct = mgmtGetAcct(pConn->pUser->acct); mgmtEstablishConn(pConn); - mTrace("login from:%x:%d", pConn->ip, htons(pConn->port)); + mTrace("login from:%x:%hu", pConn->ip, htons(pConn->port)); } } diff --git a/src/system/detail/src/vnodeShell.c b/src/system/detail/src/vnodeShell.c index 5982b7b1b5..a5f5259887 100644 --- a/src/system/detail/src/vnodeShell.c +++ b/src/system/detail/src/vnodeShell.c @@ -47,7 +47,7 @@ void *vnodeProcessMsgFromShell(char *msg, void *ahandle, void *thandle) { SShellObj *pObj = (SShellObj *)ahandle; SIntMsg * pMsg = (SIntMsg *)msg; uint32_t peerId, peerIp; - short peerPort; + uint16_t peerPort; char ipstr[20]; if (msg == NULL) { diff --git a/src/util/src/tglobalcfg.c b/src/util/src/tglobalcfg.c index ab26eda348..99c2b8e530 100644 --- a/src/util/src/tglobalcfg.c +++ b/src/util/src/tglobalcfg.c @@ -58,12 +58,12 @@ int64_t tsMsPerDay[] = {86400000L, 86400000000L}; char tsMasterIp[TSDB_IPv4ADDR_LEN] = {0}; char tsSecondIp[TSDB_IPv4ADDR_LEN] = {0}; -short tsMgmtShellPort = 6030; // udp[6030-6034] tcp[6030] -short tsVnodeShellPort = 6035; // udp[6035-6039] tcp[6035] -short tsMgmtVnodePort = 6040; // udp[6040-6044] tcp[6040] -short tsVnodeVnodePort = 6045; // tcp[6045] -short tsMgmtMgmtPort = 6050; // udp, numOfVnodes fixed to 1, range udp[6050] -short tsMgmtSyncPort = 6050; // tcp, range tcp[6050] +uint16_t tsMgmtShellPort = 6030; // udp[6030-6034] tcp[6030] +uint16_t tsVnodeShellPort = 6035; // udp[6035-6039] tcp[6035] +uint16_t tsMgmtVnodePort = 6040; // udp[6040-6044] tcp[6040] +uint16_t tsVnodeVnodePort = 6045; // tcp[6045] +uint16_t tsMgmtMgmtPort = 6050; // udp, numOfVnodes fixed to 1, range udp[6050] +uint16_t tsMgmtSyncPort = 6050; // tcp, range tcp[6050] int tsStatusInterval = 1; // second int tsShellActivityTimer = 3; // second @@ -152,8 +152,8 @@ int tsProjectExecInterval = 10000; // every 10sec, the projection will be int64_t tsMaxRetentWindow = 24 * 3600L; // maximum time window tolerance char tsHttpIp[TSDB_IPv4ADDR_LEN] = "0.0.0.0"; -short tsHttpPort = 6020; // only tcp, range tcp[6020] -// short tsNginxPort = 6060; //only tcp, range tcp[6060] +uint16_t tsHttpPort = 6020; // only tcp, range tcp[6020] +// uint16_t tsNginxPort = 6060; //only tcp, range tcp[6060] int tsHttpCacheSessions = 100; int tsHttpSessionExpire = 36000; int tsHttpMaxThreads = 2; diff --git a/src/util/src/tsocket.c b/src/util/src/tsocket.c index 9a2dafe377..6e8379c0a4 100644 --- a/src/util/src/tsocket.c +++ b/src/util/src/tsocket.c @@ -261,19 +261,19 @@ int taosReadn(int fd, char *ptr, int nbytes) { return (nbytes - nleft); } -int taosOpenUdpSocket(char *ip, short port) { +int taosOpenUdpSocket(char *ip, uint16_t port) { struct sockaddr_in localAddr; int sockFd; int ttl = 128; int reuse, nocheck; int bufSize = 8192000; - pTrace("open udp socket:%s:%d", ip, port); + pTrace("open udp socket:%s:%hu", ip, port); memset((char *)&localAddr, 0, sizeof(localAddr)); localAddr.sin_family = AF_INET; localAddr.sin_addr.s_addr = inet_addr(ip); - localAddr.sin_port = (uint16_t)htons((uint16_t)port); + localAddr.sin_port = (uint16_t)htons(port); if ((sockFd = (int)socket(AF_INET, SOCK_DGRAM, 0)) < 0) { pError("failed to open udp socket: %d (%s)", errno, strerror(errno)); @@ -319,7 +319,7 @@ int taosOpenUdpSocket(char *ip, short port) { /* bind socket to local address */ if (bind(sockFd, (struct sockaddr *)&localAddr, sizeof(localAddr)) < 0) { - pError("failed to bind udp socket: %d (%s), %s:%d", errno, strerror(errno), ip, port); + pError("failed to bind udp socket: %d (%s), %s:%hu", errno, strerror(errno), ip, port); taosCloseSocket(sockFd); return -1; } @@ -327,7 +327,7 @@ int taosOpenUdpSocket(char *ip, short port) { return sockFd; } -int taosOpenTcpClientSocket(char *destIp, short destPort, char *clientIp) { +int taosOpenTcpClientSocket(char *destIp, uint16_t destPort, char *clientIp) { int sockFd = 0; struct sockaddr_in serverAddr, clientAddr; int ret; @@ -364,7 +364,7 @@ int taosOpenTcpClientSocket(char *destIp, short destPort, char *clientIp) { ret = connect(sockFd, (struct sockaddr *)&serverAddr, sizeof(serverAddr)); if (ret != 0) { - pError("failed to connect socket, ip:%s, port:%d, reason: %s", destIp, destPort, strerror(errno)); + pError("failed to connect socket, ip:%s, port:%hu, reason: %s", destIp, destPort, strerror(errno)); taosCloseSocket(sockFd); sockFd = -1; } @@ -422,17 +422,17 @@ int taosKeepTcpAlive(int sockFd) { return 0; } -int taosOpenTcpServerSocket(char *ip, short port) { +int taosOpenTcpServerSocket(char *ip, uint16_t port) { struct sockaddr_in serverAdd; int sockFd; int reuse; - pTrace("open tcp server socket:%s:%d", ip, port); + pTrace("open tcp server socket:%s:%hu", ip, port); bzero((char *)&serverAdd, sizeof(serverAdd)); serverAdd.sin_family = AF_INET; serverAdd.sin_addr.s_addr = inet_addr(ip); - serverAdd.sin_port = (uint16_t)htons((uint16_t)port); + serverAdd.sin_port = (uint16_t)htons(port); if ((sockFd = (int)socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { pError("failed to open TCP socket: %d (%s)", errno, strerror(errno)); @@ -449,7 +449,7 @@ int taosOpenTcpServerSocket(char *ip, short port) { /* bind socket to server address */ if (bind(sockFd, (struct sockaddr *)&serverAdd, sizeof(serverAdd)) < 0) { - pError("bind tcp server socket failed, %s:%d, reason:%d(%s)", ip, port, errno, strerror(errno)); + pError("bind tcp server socket failed, %s:%hu, reason:%d(%s)", ip, port, errno, strerror(errno)); close(sockFd); return -1; } @@ -457,7 +457,7 @@ int taosOpenTcpServerSocket(char *ip, short port) { if (taosKeepTcpAlive(sockFd) < 0) return -1; if (listen(sockFd, 10) < 0) { - pError("listen tcp server socket failed, %s:%d, reason:%d(%s)", ip, port, errno, strerror(errno)); + pError("listen tcp server socket failed, %s:%hu, reason:%d(%s)", ip, port, errno, strerror(errno)); return -1; } From 7e52ceba893687c4a6f19f1a55baff9fdb4d4105 Mon Sep 17 00:00:00 2001 From: malong Date: Wed, 20 Nov 2019 13:34:39 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E6=97=B6=E9=97=B4=E7=BB=B4=E5=BA=A6?= =?UTF-8?q?=E8=81=9A=E5=90=88=E7=9A=84=E8=AF=AD=E6=B3=95=20group=20by?= =?UTF-8?q?=E5=92=8Cfill=20=E9=A1=BA=E5=BA=8F=E5=86=99=E5=8F=8D=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- documentation/webdocs/markdowndocs/TAOS SQL-ch.md | 2 +- documentation/webdocs/markdowndocs/TAOS SQL.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/webdocs/markdowndocs/TAOS SQL-ch.md b/documentation/webdocs/markdowndocs/TAOS SQL-ch.md index a6a1b4872a..6a8549bbd2 100644 --- a/documentation/webdocs/markdowndocs/TAOS SQL-ch.md +++ b/documentation/webdocs/markdowndocs/TAOS SQL-ch.md @@ -424,9 +424,9 @@ SELECT function_list FROM tb_name SELECT function_list FROM stb_name [WHERE where_condition] - [GROUP BY tags] INTERVAL (interval) [FILL ({ VALUE | PREV | NULL | LINEAR})] + [GROUP BY tags] ``` - 聚合时间段的长度由关键词INTERVAL指定,最短时间间隔10毫秒(10a)。聚合查询中,能够同时执行的聚合和选择函数仅限于单个输出的函数:count、avg、sum 、stddev、leastsquares、percentile、min、max、first、last,不能使用具有多行输出结果的函数(例如:top、bottom、diff以及四则运算)。 diff --git a/documentation/webdocs/markdowndocs/TAOS SQL.md b/documentation/webdocs/markdowndocs/TAOS SQL.md index 2431514fa5..870529417f 100644 --- a/documentation/webdocs/markdowndocs/TAOS SQL.md +++ b/documentation/webdocs/markdowndocs/TAOS SQL.md @@ -474,9 +474,9 @@ SELECT function_list FROM tb_name SELECT function_list FROM stb_name [WHERE where_condition] - [GROUP BY tags] INTERVAL (interval) [FILL ({ VALUE | PREV | NULL | LINEAR})] + [GROUP BY tags] ``` The downsampling time window is defined by `interval`, which is at least 10 milliseconds. The query returns a new series of downsampled data that has a series of fixed timestamps with an increment of `interval`. From e7f473fcf48fbc214e5cfb1135a8746bfc82748b Mon Sep 17 00:00:00 2001 From: malong Date: Wed, 20 Nov 2019 13:44:26 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BB=80=E4=B9=88=E6=98=AF=E8=B6=85?= =?UTF-8?q?=E7=BA=A7=E8=A1=A8=20=E4=BA=8B=E4=BE=8B=E4=B8=AD=E7=9A=84where?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E5=AD=97=E6=AE=B5=E5=86=99=E9=94=99=E4=BA=86?= =?UTF-8?q?=EF=BC=8Cname=E5=BA=94=E8=AF=A5=E6=94=B9=E4=B8=BAlocation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- documentation/webdocs/markdowndocs/Super Table-ch.md | 2 +- documentation/webdocs/markdowndocs/Super Table.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/webdocs/markdowndocs/Super Table-ch.md b/documentation/webdocs/markdowndocs/Super Table-ch.md index 9267e00a70..ee00eb1e86 100644 --- a/documentation/webdocs/markdowndocs/Super Table-ch.md +++ b/documentation/webdocs/markdowndocs/Super Table-ch.md @@ -218,7 +218,7 @@ GROUP BY location, type ```mysql SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree) FROM thermometer -WHERE name<>'beijing' and ts>=now-1d +WHERE location<>'beijing' and ts>=now-1d INTERVAL(10M) GROUP BY location, type ``` diff --git a/documentation/webdocs/markdowndocs/Super Table.md b/documentation/webdocs/markdowndocs/Super Table.md index 79a1650924..85c840f774 100644 --- a/documentation/webdocs/markdowndocs/Super Table.md +++ b/documentation/webdocs/markdowndocs/Super Table.md @@ -102,7 +102,7 @@ List the number of records, average, maximum, and minimum temperature every 10 m ```mysql SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree) FROM thermometer -WHERE name='beijing' and type=10 and ts>=now-1d +WHERE location='beijing' and type=10 and ts>=now-1d INTERVAL(10M) ``` From b1dbc7c69a3d63d67b7a80055164235c21370604 Mon Sep 17 00:00:00 2001 From: malong Date: Wed, 20 Nov 2019 13:48:49 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E2=80=9C=E8=B6=85=E7=BA=A7=E8=A1=A8?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E2=80=9D=E7=9A=84=E8=AF=B4=E6=98=8E=E2=80=9C?= =?UTF-8?q?2.TAGS=E5=88=97=E7=9A=84=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=98=AFtimestamp=E5=92=8Cnchar=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E8=A1=A8=E8=BF=B0=E6=9C=89=E9=97=AE=E9=A2=98=EF=BC=9B?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E6=94=AF=E6=8C=81nchar=E4=BA=86=EF=BC=8C?= =?UTF-8?q?=E5=8E=BB=E6=8E=89nchar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- documentation/webdocs/markdowndocs/Super Table-ch.md | 2 +- documentation/webdocs/markdowndocs/Super Table.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/webdocs/markdowndocs/Super Table-ch.md b/documentation/webdocs/markdowndocs/Super Table-ch.md index ee00eb1e86..0c55061324 100644 --- a/documentation/webdocs/markdowndocs/Super Table-ch.md +++ b/documentation/webdocs/markdowndocs/Super Table-ch.md @@ -54,7 +54,7 @@ STable从属于库,一个STable只属于一个库,但一个库可以有一 说明: 1. TAGS列总长度不能超过512 bytes; - 2. TAGS列的数据类型不能是timestamp和nchar类型; + 2. TAGS列的数据类型不能是timestamp; 3. TAGS列名不能与其他列名相同; 4. TAGS列名不能为预留关键字. diff --git a/documentation/webdocs/markdowndocs/Super Table.md b/documentation/webdocs/markdowndocs/Super Table.md index 85c840f774..609dd11bd2 100644 --- a/documentation/webdocs/markdowndocs/Super Table.md +++ b/documentation/webdocs/markdowndocs/Super Table.md @@ -23,7 +23,7 @@ New keyword "tags" is introduced, where tag_name is the tag name, and tag_type i Note: 1. The bytes of all tags together shall be less than 512 -2. Tag's data type can not be time stamp or nchar +2. Tag's data type can not be time stamp 3. Tag name shall be different from the field name 4. Tag name shall not be the same as system keywords 5. Maximum number of tags is 6