提交 d2605d0e 编写于 作者: S slguan

connect from client to mgmt

上级 a241006d
...@@ -324,14 +324,12 @@ typedef struct _sql_obj { ...@@ -324,14 +324,12 @@ typedef struct _sql_obj {
short vnode; short vnode;
int64_t stime; int64_t stime;
uint32_t queryId; uint32_t queryId;
void * thandle;
SRpcIpSet *ipSet;
void * pStream; void * pStream;
void * pSubscription; void * pSubscription;
char * sqlstr; char * sqlstr;
char retry; char retry;
char maxRetry; char maxRetry;
uint8_t index; SRpcIpSet *ipList;
char freed : 4; char freed : 4;
char listed : 4; char listed : 4;
tsem_t rspSem; tsem_t rspSem;
...@@ -379,8 +377,8 @@ int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion); ...@@ -379,8 +377,8 @@ int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion);
void tscInitMsgs(); void tscInitMsgs();
extern int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo); extern int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo);
void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle); void tscProcessMsgFromServer(char type, void *pCont, int contLen, void *ahandle, int32_t code);
int tscProcessSql(SSqlObj *pSql); int tscProcessSql(SSqlObj *pSql);
void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows); void tscAsyncInsertMultiVnodesProxy(void *param, TAOS_RES *tres, int numOfRows);
......
...@@ -318,13 +318,6 @@ void tscProcessAsyncRes(SSchedMsg *pMsg) { ...@@ -318,13 +318,6 @@ void tscProcessAsyncRes(SSchedMsg *pMsg) {
int cmd = pCmd->command; int cmd = pCmd->command;
int code = pRes->code ? -pRes->code : pRes->numOfRows; int code = pRes->code ? -pRes->code : pRes->numOfRows;
if ((tscKeepConn[cmd] == 0 || (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS)) &&
pSql->pStream == NULL) {
if (pSql->thandle) taosAddConnIntoCache(tscConnCache, pSql->thandle, pSql->ip, pSql->vnode, pTscObj->user);
pSql->thandle = NULL;
}
// in case of async insert, restore the user specified callback function // in case of async insert, restore the user specified callback function
bool shouldFree = tscShouldFreeAsyncSqlObj(pSql); bool shouldFree = tscShouldFreeAsyncSqlObj(pSql);
...@@ -454,8 +447,8 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) { ...@@ -454,8 +447,8 @@ void tscMeterMetaCallBack(void *param, TAOS_RES *res, int code) {
tscTrace("%p failed to renew meterMeta", pSql); tscTrace("%p failed to renew meterMeta", pSql);
tsem_post(&pSql->rspSem); tsem_post(&pSql->rspSem);
} else { } else {
tscTrace("%p renew meterMeta successfully, command:%d, code:%d, thandle:%p, retry:%d", tscTrace("%p renew meterMeta successfully, command:%d, code:%d, retry:%d",
pSql, pSql->cmd.command, pSql->res.code, pSql->thandle, pSql->retry); pSql, pSql->cmd.command, pSql->res.code, pSql->retry);
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(&pSql->cmd, 0, 0); SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(&pSql->cmd, 0, 0);
assert(pMeterMetaInfo->pMeterMeta == NULL); assert(pMeterMetaInfo->pMeterMeta == NULL);
......
...@@ -451,7 +451,6 @@ static int insertStmtExecute(STscStmt* stmt) { ...@@ -451,7 +451,6 @@ static int insertStmtExecute(STscStmt* stmt) {
pRes->numOfTotalInCurrentClause = 0; pRes->numOfTotalInCurrentClause = 0;
pRes->qhandle = 0; pRes->qhandle = 0;
pSql->thandle = NULL;
tscDoQuery(pSql); tscDoQuery(pSql);
......
...@@ -145,7 +145,7 @@ void tscKillQuery(STscObj *pObj, uint32_t killId) { ...@@ -145,7 +145,7 @@ void tscKillQuery(STscObj *pObj, uint32_t killId) {
if (pSql == NULL) return; if (pSql == NULL) return;
tscTrace("%p query is killed, queryId:%d thandle:%p", pSql, killId, pSql->thandle); tscTrace("%p query is killed, queryId:%d", pSql, killId);
taos_stop_query(pSql); taos_stop_query(pSql);
} }
......
此差异已折叠。
...@@ -64,14 +64,18 @@ TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const ...@@ -64,14 +64,18 @@ TAOS *taos_connect_imp(const char *ip, const char *user, const char *pass, const
} }
if (ip && ip[0]) { if (ip && ip[0]) {
tscMgmtIpList.numOfIps = 3; tscMgmtIpList.numOfIps = 2;
tscMgmtIpList.index = 0;
tscMgmtIpList.ip[0] = inet_addr(ip); tscMgmtIpList.ip[0] = inet_addr(ip);
tscMgmtIpList.ip[1] = inet_addr(tsMasterIp); tscMgmtIpList.ip[1] = inet_addr(tsMasterIp);
tscMgmtIpList.ip[2] = inet_addr(tsSecondIp); if (tsSecondIp[0]) {
tscMgmtIpList.index = 0; tscMgmtIpList.numOfIps = 3;
tscMgmtIpList.port = tsMgmtShellPort; tscMgmtIpList.ip[2] = inet_addr(tsSecondIp);
}
} }
tscMgmtIpList.port = port ? port : tsMgmtShellPort;
pObj = (STscObj *)malloc(sizeof(STscObj)); pObj = (STscObj *)malloc(sizeof(STscObj));
if (NULL == pObj) { if (NULL == pObj) {
globalCode = TSDB_CODE_CLI_OUT_OF_MEMORY; globalCode = TSDB_CODE_CLI_OUT_OF_MEMORY;
...@@ -208,7 +212,6 @@ int taos_query_imp(STscObj *pObj, SSqlObj *pSql) { ...@@ -208,7 +212,6 @@ int taos_query_imp(STscObj *pObj, SSqlObj *pSql) {
* to free connection, which may cause segment fault, when the parse phrase is not even successfully executed. * to free connection, which may cause segment fault, when the parse phrase is not even successfully executed.
*/ */
pRes->qhandle = 0; pRes->qhandle = 0;
pSql->thandle = NULL;
if (pRes->code == TSDB_CODE_SUCCESS) { if (pRes->code == TSDB_CODE_SUCCESS) {
tscDoQuery(pSql); tscDoQuery(pSql);
...@@ -713,7 +716,6 @@ void taos_free_result_imp(TAOS_RES* res, int keepCmd) { ...@@ -713,7 +716,6 @@ void taos_free_result_imp(TAOS_RES* res, int keepCmd) {
/* Query rsp is not received from vnode, so the qhandle is NULL */ /* Query rsp is not received from vnode, so the qhandle is NULL */
tscTrace("%p qhandle is null, abort free, fp:%p", pSql, pSql->fp); tscTrace("%p qhandle is null, abort free, fp:%p", pSql, pSql->fp);
if (pSql->fp != NULL) { if (pSql->fp != NULL) {
pSql->thandle = NULL;
tscFreeSqlObj(pSql); tscFreeSqlObj(pSql);
tscTrace("%p Async SqlObj is freed by app", pSql); tscTrace("%p Async SqlObj is freed by app", pSql);
} else if (keepCmd) { } else if (keepCmd) {
...@@ -774,7 +776,6 @@ void taos_free_result_imp(TAOS_RES* res, int keepCmd) { ...@@ -774,7 +776,6 @@ void taos_free_result_imp(TAOS_RES* res, int keepCmd) {
* *
* Then this object will be reused and no free operation is required. * Then this object will be reused and no free operation is required.
*/ */
pSql->thandle = NULL;
if (keepCmd) { if (keepCmd) {
tscFreeSqlResult(pSql); tscFreeSqlResult(pSql);
tscTrace("%p sql result is freed by app while sql command is kept", pSql); tscTrace("%p sql result is freed by app while sql command is kept", pSql);
...@@ -785,7 +786,6 @@ void taos_free_result_imp(TAOS_RES* res, int keepCmd) { ...@@ -785,7 +786,6 @@ void taos_free_result_imp(TAOS_RES* res, int keepCmd) {
} }
} else { } else {
// if no free resource msg is sent to vnode, we free this object immediately. // if no free resource msg is sent to vnode, we free this object immediately.
pSql->thandle = NULL;
if (pSql->fp) { if (pSql->fp) {
assert(pRes->numOfRows == 0 || (pCmd->command > TSDB_SQL_LOCAL)); assert(pRes->numOfRows == 0 || (pCmd->command > TSDB_SQL_LOCAL));
...@@ -899,11 +899,6 @@ void taos_stop_query(TAOS_RES *res) { ...@@ -899,11 +899,6 @@ void taos_stop_query(TAOS_RES *res) {
return; return;
} }
if (pSql->thandle == NULL) {
tscTrace("%p no connection, abort cancel", res);
return;
}
//taosStopRpcConn(pSql->thandle); //taosStopRpcConn(pSql->thandle);
tscTrace("%p query is cancelled", res); tscTrace("%p query is cancelled", res);
} }
...@@ -1147,7 +1142,6 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { ...@@ -1147,7 +1142,6 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
* to free connection, which may cause segment fault, when the parse phrase is not even successfully executed. * to free connection, which may cause segment fault, when the parse phrase is not even successfully executed.
*/ */
pRes->qhandle = 0; pRes->qhandle = 0;
pSql->thandle = NULL;
free(str); free(str);
if (pRes->code != TSDB_CODE_SUCCESS) { if (pRes->code != TSDB_CODE_SUCCESS) {
......
...@@ -382,7 +382,6 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) { ...@@ -382,7 +382,6 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) {
pRes->numOfRows = 1; pRes->numOfRows = 1;
pRes->numOfTotal = 0; pRes->numOfTotal = 0;
pRes->qhandle = 0; pRes->qhandle = 0;
pSql->thandle = NULL;
pSql->cmd.command = TSDB_SQL_SELECT; pSql->cmd.command = TSDB_SQL_SELECT;
pQueryInfo->type = type; pQueryInfo->type = type;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册