未验证 提交 436f4b78 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #3112 from taosdata/master

Merge from master into develop
......@@ -118,6 +118,7 @@ static void balanceSwapVnodeGid(SVnodeGid *pVnodeGid1, SVnodeGid *pVnodeGid2) {
}
int32_t balanceAllocVnodes(SVgObj *pVgroup) {
static int32_t randIndex = 0;
int32_t dnode = 0;
int32_t vnodes = 0;
......@@ -160,7 +161,7 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) {
*/
if (pVgroup->numOfVnodes == 1) {
} else if (pVgroup->numOfVnodes == 2) {
if (rand() % 2 == 0) {
if (randIndex++ % 2 == 0) {
balanceSwapVnodeGid(pVgroup->vnodeGid, pVgroup->vnodeGid + 1);
}
} else {
......
......@@ -3,6 +3,7 @@ taos_init
taos_cleanup
taos_options
taos_connect
taos_connect_auth
taos_close
taos_stmt_init
taos_stmt_prepare
......
......@@ -16,6 +16,7 @@
#include "hash.h"
#include "os.h"
#include "qAst.h"
#include "tkey.h"
#include "tcache.h"
#include "tnote.h"
#include "trpc.h"
......@@ -47,18 +48,37 @@ static bool validPassword(const char* passwd) {
return validImpl(passwd, TSDB_PASSWORD_LEN - 1);
}
SSqlObj *taosConnectImpl(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) {
SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, const char *auth, const char *db,
uint16_t port, void (*fp)(void *, TAOS_RES *, int), void *param, void **taos) {
taos_init();
if (!validUserName(user)) {
terrno = TSDB_CODE_TSC_INVALID_USER_LENGTH;
return NULL;
}
if (!validPassword(pass)) {
terrno = TSDB_CODE_TSC_INVALID_PASS_LENGTH;
return NULL;
char secretEncrypt[32] = {0};
int secretEncryptLen = 0;
if (auth == NULL) {
if (!validPassword(pass)) {
terrno = TSDB_CODE_TSC_INVALID_PASS_LENGTH;
return NULL;
}
taosEncryptPass((uint8_t *)pass, strlen(pass), secretEncrypt);
} else {
int outlen = 0;
int len = (int)strlen(auth);
char *base64 = (char *)base64_decode(auth, len, &outlen);
if (base64 == NULL || outlen == 0) {
tscError("invalid auth info:%s", auth);
free(base64);
terrno = TSDB_CODE_TSC_INVALID_PASS_LENGTH;
return NULL;
} else {
memcpy(secretEncrypt, base64, outlen);
free(base64);
}
secretEncryptLen = outlen;
}
if (ip) {
......@@ -67,7 +87,7 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
}
void *pDnodeConn = NULL;
if (tscInitRpc(user, pass, &pDnodeConn) != 0) {
if (tscInitRpc(user, secretEncrypt, &pDnodeConn) != 0) {
terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL;
return NULL;
}
......@@ -82,7 +102,8 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
pObj->signature = pObj;
tstrncpy(pObj->user, user, sizeof(pObj->user));
taosEncryptPass((uint8_t *)pass, strlen(pass), pObj->pass);
secretEncryptLen = MIN(secretEncryptLen, sizeof(pObj->pass));
memcpy(pObj->pass, secretEncrypt, secretEncryptLen);
if (db) {
int32_t len = (int32_t)strlen(db);
......@@ -144,20 +165,17 @@ static void syncConnCallback(void *param, TAOS_RES *tres, int code) {
tsem_post(&pSql->rspSem);
}
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
tscDebug("try to create a connection to %s:%u, user:%s db:%s", ip, port, user, db);
if (user == NULL) user = TSDB_DEFAULT_USER;
if (pass == NULL) pass = TSDB_DEFAULT_PASS;
STscObj* pObj = NULL;
SSqlObj *pSql = taosConnectImpl(ip, user, pass, db, port, syncConnCallback, NULL, (void**) &pObj);
TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, const char *auth, const char *db,
uint16_t port) {
STscObj *pObj = NULL;
SSqlObj *pSql = taosConnectImpl(ip, user, pass, auth, db, port, syncConnCallback, NULL, (void **)&pObj);
if (pSql != NULL) {
pSql->fp = syncConnCallback;
pSql->param = pSql;
tscProcessSql(pSql);
tsem_wait(&pSql->rspSem);
if (pSql->res.code != TSDB_CODE_SUCCESS) {
terrno = pSql->res.code;
taos_free_result(pSql);
......@@ -182,23 +200,38 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
return NULL;
}
TAOS *taos_connect_c(const char *ip, uint8_t ipLen, const char *user, uint8_t userLen,
const char *pass, uint8_t passLen, const char *db, uint8_t dbLen, uint16_t port) {
char ipBuf[TSDB_EP_LEN] = {0};
char userBuf[TSDB_USER_LEN] = {0};
char passBuf[TSDB_PASSWORD_LEN] = {0};
char dbBuf[TSDB_DB_NAME_LEN] = {0};
strncpy(ipBuf, ip, MIN(TSDB_EP_LEN - 1, ipLen));
strncpy(userBuf, user, MIN(TSDB_USER_LEN - 1, userLen));
strncpy(passBuf, pass, MIN(TSDB_PASSWORD_LEN - 1,passLen));
strncpy(dbBuf, db, MIN(TSDB_DB_NAME_LEN - 1, dbLen));
return taos_connect(ipBuf, userBuf, passBuf, dbBuf, port);
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
tscDebug("try to create a connection to %s:%u, user:%s db:%s", ip, port, user, db);
if (user == NULL) user = TSDB_DEFAULT_USER;
if (pass == NULL) pass = TSDB_DEFAULT_PASS;
return taos_connect_internal(ip, user, pass, NULL, db, port);
}
TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port) {
tscDebug("try to create a connection to %s:%u by auth, user:%s db:%s", ip, port, user, db);
if (user == NULL) user = TSDB_DEFAULT_USER;
if (auth == NULL) return NULL;
return taos_connect_internal(ip, user, NULL, auth, db, port);
}
TAOS *taos_connect_c(const char *ip, uint8_t ipLen, const char *user, uint8_t userLen, const char *pass,
uint8_t passLen, const char *db, uint8_t dbLen, uint16_t port) {
char ipBuf[TSDB_EP_LEN] = {0};
char userBuf[TSDB_USER_LEN] = {0};
char passBuf[TSDB_PASSWORD_LEN] = {0};
char dbBuf[TSDB_DB_NAME_LEN] = {0};
strncpy(ipBuf, ip, MIN(TSDB_EP_LEN - 1, ipLen));
strncpy(userBuf, user, MIN(TSDB_USER_LEN - 1, userLen));
strncpy(passBuf, pass, MIN(TSDB_PASSWORD_LEN - 1, passLen));
strncpy(dbBuf, db, MIN(TSDB_DB_NAME_LEN - 1, dbLen));
return taos_connect(ipBuf, userBuf, passBuf, dbBuf, port);
}
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) {
SSqlObj* pSql = taosConnectImpl(ip, user, pass, db, port, fp, param, taos);
SSqlObj* pSql = taosConnectImpl(ip, user, pass, NULL, db, port, fp, param, taos);
if (pSql == NULL) {
return NULL;
}
......
......@@ -47,10 +47,8 @@ void tscCheckDiskUsage(void *UNUSED_PARAM(para), void* UNUSED_PARAM(param)) {
taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr);
}
int32_t tscInitRpc(const char *user, const char *secret, void** pDnodeConn) {
int32_t tscInitRpc(const char *user, const char *secretEncrypt, void **pDnodeConn) {
SRpcInit rpcInit;
char secretEncrypt[32] = {0};
taosEncryptPass((uint8_t *)secret, strlen(secret), secretEncrypt);
if (*pDnodeConn == NULL) {
memset(&rpcInit, 0, sizeof(rpcInit));
......@@ -60,11 +58,11 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pDnodeConn) {
rpcInit.cfp = tscProcessMsgFromServer;
rpcInit.sessions = tsMaxConnections;
rpcInit.connType = TAOS_CONN_CLIENT;
rpcInit.user = (char*)user;
rpcInit.user = (char *)user;
rpcInit.idleTime = 2000;
rpcInit.ckey = "key";
rpcInit.spi = 1;
rpcInit.secret = secretEncrypt;
rpcInit.secret = (char *)secretEncrypt;
*pDnodeConn = rpcOpen(&rpcInit);
if (*pDnodeConn == NULL) {
......
......@@ -113,6 +113,7 @@ extern char tsInternalPass[];
extern int32_t tsMonitorInterval;
// internal
extern int32_t tsPrintAuth;
extern int32_t tscEmbedded;
extern char configDir[];
extern char tsVnodeDir[];
......
......@@ -146,6 +146,7 @@ char tsInternalPass[] = "secretkey";
int32_t tsMonitorInterval = 30; // seconds
// internal
int32_t tsPrintAuth = 0;
int32_t tscEmbedded = 0;
char configDir[TSDB_FILENAME_LEN] = {0};
char tsVnodeDir[TSDB_FILENAME_LEN] = {0};
......
......@@ -23,7 +23,9 @@
// TODO refactor to set the tz value through parameter
void tsSetTimeZone() {
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
uInfo("timezone is set to %s by %s", tsTimezone, tsCfgStatusStr[cfg_timezone->cfgStatus]);
if (cfg_timezone != NULL) {
uInfo("timezone is set to %s by %s", tsTimezone, tsCfgStatusStr[cfg_timezone->cfgStatus]);
}
#ifdef WINDOWS
char winStr[TSDB_LOCALE_LEN * 2];
......
......@@ -449,7 +449,12 @@ static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) {
}
void dnodeUpdateMnodeEpSetForPeer(SRpcEpSet *pEpSet) {
dInfo("mnode EP list for is changed, numOfEps:%d inUse:%d", pEpSet->numOfEps, pEpSet->inUse);
if (pEpSet->numOfEps <= 0) {
dError("mnode EP list for peer is changed, but content is invalid, discard it");
return;
}
dInfo("mnode EP list for peer is changed, numOfEps:%d inUse:%d", pEpSet->numOfEps, pEpSet->inUse);
for (int i = 0; i < pEpSet->numOfEps; ++i) {
pEpSet->port[i] -= TSDB_PORT_DNODEDNODE;
dInfo("mnode index:%d %s:%u", i, pEpSet->fqdn[i], pEpSet->port[i])
......@@ -710,10 +715,10 @@ static void dnodeSendStatusMsg(void *handle, void *tmrId) {
pStatus->clusterCfg.statusInterval = htonl(tsStatusInterval);
pStatus->clusterCfg.maxtablesPerVnode = htonl(tsMaxTablePerVnode);
pStatus->clusterCfg.maxVgroupsPerDb = htonl(tsMaxVgroupsPerDb);
strcpy(pStatus->clusterCfg.arbitrator, tsArbitrator);
strcpy(pStatus->clusterCfg.timezone, tsTimezone);
strcpy(pStatus->clusterCfg.locale, tsLocale);
strcpy(pStatus->clusterCfg.charset, tsCharset);
tstrncpy(pStatus->clusterCfg.arbitrator, tsArbitrator, TSDB_EP_LEN);
tstrncpy(pStatus->clusterCfg.timezone, tsTimezone, 64);
tstrncpy(pStatus->clusterCfg.locale, tsLocale, TSDB_LOCALE_LEN);
tstrncpy(pStatus->clusterCfg.charset, tsCharset, TSDB_LOCALE_LEN);
vnodeBuildStatusMsg(pStatus);
contLen = sizeof(SDMStatusMsg) + pStatus->openVnodes * sizeof(SVnodeLoad);
......
......@@ -52,6 +52,8 @@ int32_t main(int32_t argc, char *argv[]) {
} else if (strcmp(argv[i], "-k") == 0) {
grantParseParameter();
exit(EXIT_SUCCESS);
} else if (strcmp(argv[i], "-A") == 0) {
tsPrintAuth = 1;
}
#ifdef TAOS_MEM_CHECK
else if (strcmp(argv[i], "--alloc-random-fail") == 0) {
......
......@@ -39,6 +39,7 @@ typedef struct SShellArguments {
char* host;
char* password;
char* user;
char* auth;
char* database;
char* timezone;
bool is_raw_time;
......
......@@ -32,16 +32,16 @@ void insertChar(Command *cmd, char *c, int size);
void printHelp() {
char indent[10] = " ";
printf("taos shell is used to test the TDEngine database\n");
printf("taos shell is used to test the TDengine database\n");
printf("%s%s\n", indent, "-h");
printf("%s%s%s\n", indent, indent, "TDEngine server IP address to connect. The default host is localhost.");
printf("%s%s%s\n", indent, indent, "TDengine server IP address to connect. The default host is localhost.");
printf("%s%s\n", indent, "-p");
printf("%s%s%s\n", indent, indent, "The password to use when connecting to the server.");
printf("%s%s\n", indent, "-P");
printf("%s%s%s\n", indent, indent, "The TCP/IP port number to use for the connection");
printf("%s%s\n", indent, "-u");
printf("%s%s%s\n", indent, indent, "The TDEngine user name to use when connecting to the server.");
printf("%s%s%s\n", indent, indent, "The user name to use when connecting to the server.");
printf("%s%s\n", indent, "-c");
printf("%s%s%s\n", indent, indent, "Configuration directory.");
printf("%s%s\n", indent, "-s");
......
......@@ -38,6 +38,7 @@ SShellHistory history;
#define DEFAULT_MAX_BINARY_DISPLAY_WIDTH 30
extern int32_t tsMaxBinaryDisplayWidth;
extern TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port);
/*
* FUNCTION: Initialize the shell.
......@@ -70,7 +71,13 @@ TAOS *shellInit(SShellArguments *args) {
tsTableMetaKeepTimer = 3000;
// Connect to the database.
TAOS *con = taos_connect(args->host, args->user, args->password, args->database, args->port);
TAOS *con = NULL;
if (args->auth == NULL) {
con = taos_connect(args->host, args->user, args->password, args->database, args->port);
} else {
con = taos_connect_auth(args->host, args->user, args->auth, args->database, args->port);
}
if (con == NULL) {
printf("taos connect failed, reason: %s.\n\n", tstrerror(terrno));
fflush(stdout);
......
......@@ -33,10 +33,11 @@ const char *argp_program_bug_address = "<support@taosdata.com>";
static char doc[] = "";
static char args_doc[] = "";
static struct argp_option options[] = {
{"host", 'h', "HOST", 0, "TDEngine server IP address to connect. The default host is localhost."},
{"host", 'h', "HOST", 0, "TDengine server IP address to connect. The default host is localhost."},
{"password", 'p', "PASSWORD", OPTION_ARG_OPTIONAL, "The password to use when connecting to the server."},
{"port", 'P', "PORT", 0, "The TCP/IP port number to use for the connection."},
{"user", 'u', "USER", 0, "The TDEngine user name to use when connecting to the server."},
{"user", 'u', "USER", 0, "The user name to use when connecting to the server."},
{"user", 'A', "Auth", 0, "The user auth to use when connecting to the server."},
{"config-dir", 'c', "CONFIG_DIR", 0, "Configuration directory."},
{"commands", 's', "COMMANDS", 0, "Commands to run without enter the shell."},
{"raw-time", 'r', 0, 0, "Output time as uint64_t."},
......@@ -76,11 +77,14 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case 'u':
arguments->user = arg;
break;
case 'A':
arguments->auth = arg;
break;
case 'c':
if (wordexp(arg, &full_path, 0) != 0) {
fprintf(stderr, "Invalid path %s\n", arg);
return -1;
}
}
if (strlen(full_path.we_wordv[0]) >= TSDB_FILENAME_LEN) {
fprintf(stderr, "config file path: %s overflow max len %d\n", full_path.we_wordv[0], TSDB_FILENAME_LEN - 1);
wordfree(&full_path);
......
......@@ -21,16 +21,18 @@ extern char configDir[];
void printHelp() {
char indent[10] = " ";
printf("taos shell is used to test the TDEngine database\n");
printf("taos shell is used to test the TDengine database\n");
printf("%s%s\n", indent, "-h");
printf("%s%s%s\n", indent, indent, "TDEngine server IP address to connect. The default host is localhost.");
printf("%s%s%s\n", indent, indent, "TDengine server IP address to connect. The default host is localhost.");
printf("%s%s\n", indent, "-p");
printf("%s%s%s\n", indent, indent, "The password to use when connecting to the server.");
printf("%s%s\n", indent, "-P");
printf("%s%s%s\n", indent, indent, "The TCP/IP port number to use for the connection");
printf("%s%s\n", indent, "-u");
printf("%s%s%s\n", indent, indent, "The TDEngine user name to use when connecting to the server.");
printf("%s%s%s\n", indent, indent, "The user name to use when connecting to the server.");
printf("%s%s\n", indent, "-A");
printf("%s%s%s\n", indent, indent, "The user auth to use when connecting to the server.");
printf("%s%s\n", indent, "-c");
printf("%s%s%s\n", indent, indent, "Configuration directory.");
printf("%s%s\n", indent, "-s");
......@@ -79,6 +81,13 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
fprintf(stderr, "option -u requires an argument\n");
exit(EXIT_FAILURE);
}
} else if (strcmp(argv[i], "-A") == 0) {
if (i < argc - 1) {
arguments->auth = argv[++i];
} else {
fprintf(stderr, "option -A requires an argument\n");
exit(EXIT_FAILURE);
}
} else if (strcmp(argv[i], "-c") == 0) {
if (i < argc - 1) {
if (strlen(argv[++i]) >= TSDB_FILENAME_LEN) {
......
......@@ -85,9 +85,9 @@ typedef struct DemoArguments {
#ifdef LINUX
/* The options we understand. */
static struct argp_option options[] = {
{0, 'h', "host", 0, "The host to connect to TDEngine. Default is localhost.", 0},
{0, 'h', "host", 0, "The host to connect to TDengine. Default is localhost.", 0},
{0, 'p', "port", 0, "The TCP/IP port number to use for the connection. Default is 0.", 1},
{0, 'u', "user", 0, "The TDEngine user name to use when connecting to the server. Default is 'root'.", 2},
{0, 'u', "user", 0, "The TDengine user name to use when connecting to the server. Default is 'root'.", 2},
{0, 'P', "password", 0, "The password to use when connecting to the server. Default is 'taosdata'.", 3},
{0, 'd', "database", 0, "Destination database. Default is 'test'.", 3},
{0, 'm', "table_prefix", 0, "Table prefix name. Default is 't'.", 3},
......@@ -264,11 +264,11 @@ typedef struct DemoArguments {
void printHelp() {
char indent[10] = " ";
printf("%s%s\n", indent, "-h");
printf("%s%s%s\n", indent, indent, "host, The host to connect to TDEngine. Default is localhost.");
printf("%s%s%s\n", indent, indent, "host, The host to connect to TDengine. Default is localhost.");
printf("%s%s\n", indent, "-p");
printf("%s%s%s\n", indent, indent, "port, The TCP/IP port number to use for the connection. Default is 0.");
printf("%s%s\n", indent, "-u");
printf("%s%s%s\n", indent, indent, "user, The TDEngine user name to use when connecting to the server. Default is 'root'.");
printf("%s%s%s\n", indent, indent, "user, The user name to use when connecting to the server. Default is 'root'.");
printf("%s%s\n", indent, "-p");
printf("%s%s%s\n", indent, indent, "password, The password to use when connecting to the server. Default is 'taosdata'.");
printf("%s%s\n", indent, "-d");
......
......@@ -73,9 +73,9 @@ static int32_t mnodeDbActionInsert(SSdbOper *pOper) {
pthread_mutex_lock(&pDb->mutex);
pDb->vgListSize = VG_LIST_SIZE;
pDb->vgList = calloc(pDb->vgListSize, sizeof(SVgObj *));
pDb->numOfVgroups = 0;
pthread_mutex_unlock(&pDb->mutex);
pDb->numOfVgroups = 0;
pDb->numOfTables = 0;
pDb->numOfSuperTables = 0;
......@@ -927,7 +927,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
if (quorum >= 0 && quorum != pDb->cfg.quorum) {
mDebug("db:%s, quorum:%d change to %d", pDb->name, pDb->cfg.quorum, quorum);
newCfg.compression = quorum;
newCfg.quorum = quorum;
}
return newCfg;
......
......@@ -58,7 +58,8 @@ int32_t mnodeProcessPeerReq(SMnodeMsg *pMsg) {
rpcRsp->rsp = epSet;
rpcRsp->len = sizeof(SRpcEpSet);
mDebug("%p, msg:%s in mpeer queue, will be redireced inUse:%d", pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType], epSet->inUse);
mDebug("%p, msg:%s in mpeer queue, will be redireced, numOfEps:%d inUse:%d", pMsg->rpcMsg.ahandle,
taosMsg[pMsg->rpcMsg.msgType], epSet->numOfEps, epSet->inUse);
for (int32_t i = 0; i < epSet->numOfEps; ++i) {
mDebug("mnode index:%d ep:%s:%d", i, epSet->fqdn[i], htons(epSet->port[i]));
}
......
......@@ -20,6 +20,7 @@
#include "tglobal.h"
#include "tgrant.h"
#include "tdataformat.h"
#include "tkey.h"
#include "mnode.h"
#include "dnode.h"
#include "mnodeDef.h"
......@@ -100,6 +101,32 @@ static int32_t mnodeUserActionDecode(SSdbOper *pOper) {
return TSDB_CODE_SUCCESS;
}
static void mnodePrintUserAuth() {
FILE *fp = fopen("auth.txt", "w");
if (!fp) {
mDebug("failed to auth.txt for write");
return;
}
void * pIter = NULL;
SUserObj *pUser = NULL;
while (1) {
pIter = mnodeGetNextUser(pIter, &pUser);
if (pUser == NULL) break;
char *base64 = base64_encode((const unsigned char *)pUser->pass, TSDB_KEY_LEN * 2);
fprintf(fp, "user:%24s auth:%s\n", pUser->user, base64);
free(base64);
mnodeDecUserRef(pUser);
}
fflush(fp);
sdbFreeIter(pIter);
fclose(fp);
}
static int32_t mnodeUserActionRestored() {
int32_t numOfRows = sdbGetNumOfRows(tsUserSdb);
if (numOfRows <= 0 && dnodeIsFirstDeploy()) {
......@@ -111,6 +138,11 @@ static int32_t mnodeUserActionRestored() {
mnodeDecAcctRef(pAcct);
}
if (tsPrintAuth != 0) {
mInfo("print user auth, for -A parameter is set");
mnodePrintUserAuth();
}
return TSDB_CODE_SUCCESS;
}
......
......@@ -170,6 +170,7 @@ static void taosGetSystemTimezone() {
fclose(f);
buf[sizeof(buf) - 1] = 0;
char *lineEnd = strstr(buf, "\n");
if (lineEnd != NULL) {
*lineEnd = 0;
......
......@@ -210,10 +210,14 @@ void httpProcessSingleSqlRetrieveCallBack(void *param, TAOS_RES *result, int num
}
}
#if 0
// todo refactor
if (tscResultsetFetchCompleted(result)) {
httpDebug("context:%p, fd:%d, ip:%s, user:%s, resultset fetch completed", pContext, pContext->fd, pContext->ipstr,
pContext->user);
isContinue = false;
}
#endif
if (isContinue) {
// retrieve next batch of rows
......
......@@ -70,14 +70,27 @@ int32_t mqttInitSystem() {
recntStatus.port = strbetween("'1883'", "'", "'");
}
topicPath = strbetween(strstr(url, strstr(_begin_hostname, ":") != NULL ? recntStatus.port : recntStatus.hostname),
"/", "/");
char* _topic = "+/+/+/";
int _tpsize = strlen(topicPath) + strlen(_topic) + 1;
recntStatus.topic = calloc(1, _tpsize);
sprintf(recntStatus.topic, "/%s/%s", topicPath, _topic);
recntStatus.client_id = strlen(tsMqttBrokerClientId) < 3 ? tsMqttBrokerClientId : "taos_mqtt";
mqttConnect = NULL;
char* portStr = recntStatus.hostname;
if (_begin_hostname != NULL) {
char* colonStr = strstr(_begin_hostname, ":");
if (colonStr != NULL) {
portStr = recntStatus.port;
}
}
char* topicStr = strstr(url, portStr);
if (topicStr != NULL) {
topicPath = strbetween(topicStr, "/", "/");
char* _topic = "+/+/+/";
int _tpsize = strlen(topicPath) + strlen(_topic) + 1;
recntStatus.topic = calloc(1, _tpsize);
sprintf(recntStatus.topic, "/%s/%s", topicPath, _topic);
recntStatus.client_id = strlen(tsMqttBrokerClientId) < 3 ? tsMqttBrokerClientId : "taos_mqtt";
mqttConnect = NULL;
} else {
topicPath = NULL;
}
return rc;
}
......
......@@ -371,7 +371,7 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
serverAdd.sin_addr.s_addr = ip;
serverAdd.sin_port = (uint16_t)htons(port);
if ((sockFd = (int)socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
if ((sockFd = (int)socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 2) {
uError("failed to open TCP socket: %d (%s)", errno, strerror(errno));
return -1;
}
......@@ -382,7 +382,7 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
uError("setsockopt SO_REUSEADDR failed: %d (%s)", errno, strerror(errno));
taosCloseSocket(sockFd);
return -1;
};
}
/* bind socket to server address */
if (bind(sockFd, (struct sockaddr *)&serverAdd, sizeof(serverAdd)) < 0) {
......
char version[12] = "2.0.0.6";
char version[12] = "2.0.1.0";
char compatible_version[12] = "2.0.0.0";
char gitinfo[48] = "e9a20fafbe9e3b0b12cbdf55604163b4b9a41b41";
char gitinfoOfInternal[48] = "dd679db0b9edeedad68574c1e031544711a9831f";
char buildinfo[64] = "Built by at 2020-08-12 07:59";
char gitinfo[48] = "7ac6c2b8de3cd66e180132fc1cf77715237308a1";
char gitinfoOfInternal[48] = "e1e64838ece2b6dbe964ec3a39953455f354d930";
char buildinfo[64] = "Built by root at 2020-08-17 11:13";
void libtaos_2_0_0_6_Linux_x64() {};
void libtaos_2_0_1_0_Linux_x64() {};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册