diff --git a/src/client/inc/tscCache.h b/src/client/inc/tscCache.h index 096a6618f6e9fdef2a39886b9c55c2f960bc3c44..4c6acec096c01db64b09c4f0d18f404b8825f7b6 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 e0c073d153bba06ab62277817a3c069829d8023a..47f25babe048394047092eb2ca40a25235b8d39b 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 44bfc978a39223f5f2d67b9f922f8f09bcdd44df..7341d674d35d4ccdc5e122b5a9a9d4205f7f8306 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 f508857ce1bc1477dc898de400b96c234ffe9bd8..1ac32d7502ee99c38f84445cfeb767ad316b06ed 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 350167a3b35ba8e1dbf32c5b93bb6011e09adddf..61bc9dd99ee7254015f6c457843b70c4c60223d1 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 c66d524fee1912f8bcb963a7d009efea0c87da80..f5727677c57bf38922bed9f7fc3fd7b9bd81ab63 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 6ec8f425cad4cc2909839e5f09e41c90d0f42cba..13c5669fec2e6beaedcbf3dd1876f05a969244f7 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 f645039441ffa126accc28ff794aa5f2e3fc2171..389aecfb7b6a3ea047251d45d853b8f3e873021d 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 05acc9155135581c0798b89a0f3bf52ecea3e2b9..2fd6d8be927a310e0131b62a8f0ecf55ae943ef2 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 e75404ad988f6b78a60a96df15a51c2b0b473b5b..d02251c2121966633e96d5167bb44f452512bb7a 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 09ced23c91c073ba9b6208a13be1cf789ef17dd5..577f3e8c8975bbb6cf734dc75d37d69793327813 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 ef86e672d1db50413cccbed8755068a583a92473..97a0c905f8c3584fee0de46b064f79a78db19f15 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 0a02fcf551d210ed2de5e53ca83e1697a2cfcd11..9eb4c26464538fc3ea9d6f088cfb209192636493 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 47ed92e2f7fd7be1c83f181d2fbcaeb00cc2dbe0..37530e1e8ce87d3a2a8e0a74abbb154ead6b770f 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 f168a0d90fd68477d57019f81af0494e643a0c7f..c8ef3bc0481c72d284485d7c369db97de6d780e9 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 e7ac0365c25109512be67e390cf7c6c4868ed3ef..72ef9f222ab3b541d928b6b948a20133becd15be 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 9254658d58818166b9ff45e7ac765735e4f47f9a..0e3b211abba01387085489e0433b9b9940cf2f5c 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 4d6577c8f3718ad9ecd576a55a19049ad0513c1b..c4b04365d39890e5d8041b2c48aa9b180575f10f 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 de37c76edd59058f0f99a63f96f425b383af405f..133bb4893cc9aa2f8b561036ffaff6a53e0db3a7 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 6a7225b47693f9c76c25fcdd3149d28381df77cf..a166603615b41c23d792cd0f384f3de9e4625e70 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 17293c3915aa73aac226df0fdb798b523a66bdbc..9f40dae434b0dba2c511cf9b837a53a8a8910250 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 a51d807aa2481b59129d54a5a48d008c06d18d70..d5e25693d0b591eddf0a5da2469e86972bb5be00 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 262673af6299df3b474fa385e6a9191f8e213d77..4acf8b3fbbab14702b3f4e98dc40b0f68fa3a3e2 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 8c2131f1f6bbdb9a90712caef73d6361ca361e1b..8427c6f162fa0906af0c51e9ff49ad7e85c4b5a5 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 3e3feb46918f3767da89a5a6fa9353fc0a89a17a..ba3bd25719f05372ab97b1dc67a92d244e03ae64 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 c90e21f510dd424d898c22980995fabb2285fee0..27c7593090d89d34b77ba34cf6c2f8b8366f2bd6 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 2c46e53258968df951fc00c4270036c08c076270..6b76c4b59e236418c408fabaac5c717cbbafcc55 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 3aa50cf168de8feabfe35f8964a59bc8e6995086..643622dfa7a66fe88b0137720772d22a5b9a0a77 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 8e6f91a66158722afc3b601538a21554ad847d50..3d39be92fe4fd1c4476e35d56b88ed2fa5c9e474 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 fee506256bb3185a4f2a8fa676927f01824cf7dc..29ada20bc427455edf8c5b771178a33aa8214ba3 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 7a4961f90c2b7d71991ece4d4d64afac32e33fd6..43fee4c08900663e0a78e34e42472f42bfadaa6c 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 702eb008758a2974990db5ada64dd4d92bc6be04..7cdc36a4465e1b71cce722719083d5476c27dd12 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 e450983dd7ef6d90d33f9eb5e1d4e2e502fefd32..25646fbb1a88e2bd971d90b35fa8ecaf4cc42374 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 40385d2fc4b6d61727c679d7781ec8cc6c5e49f5..13275300a6f2cc024b17a48346fcb148ec85e1f5 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 bd5540e5ee806ad0534dca0b238f63906fe7053f..e7dbeaaa254da098dcdac5a15b6b0feccb5f32f2 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 e58938bdadab464bffe04e17cc390fc0876fe75b..450527d009e6304f539cd7d5924c307e257e8e96 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 5982b7b1b5daa424340cb6ca76610332fd08bf01..a5f5259887efbf66dcdd16416e61cec952b992d0 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 ab26eda348e0a9c1bb8af2a649a779d449056cee..99c2b8e5301c0b8b96962b83111c1fdd3bc6a100 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 9a2dafe377b396927351763b09b95428c899a7c2..6e8379c0a486aa35433742dea1af7b10ea3be682 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; }