From 3414548772e69ff920a4f159f380a98dab87438c Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sat, 2 Jan 2021 12:11:30 +0000 Subject: [PATCH] share mgmt ep set --- src/client/inc/tsclient.h | 2 +- src/client/src/tscSql.c | 3 +-- src/client/src/tscSystem.c | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index c11c524f96..d6cf9a6553 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -385,7 +385,7 @@ void tscSetStreamDestTable(SSqlStream* pStream, const char* dstTable); void *tscAcquireRpc(const char *key); void tscReleaseRpc(void *param); -int32_t tscInitRpc(const char *key, const char *user, const char *secret, void **pRpcObj); +int32_t tscInitRpc(const char *key, const char *user, const char *secret, void **pRpcObj, SRpcCorEpSet *corMgmtEpSet); void tscInitMsgsFp(); int tsParseSql(SSqlObj *pSql, bool initial); diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 0f1824c1ed..653574c8d0 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -94,7 +94,7 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa sprintf(rpcKey, "%s:%s:%s:%d", user, pass, ip, port); void *pRpcObj = NULL; - if (tscInitRpc(rpcKey, user, secretEncrypt, &pRpcObj) != 0) { + if (tscInitRpc(rpcKey, user, secretEncrypt, &pRpcObj, &corMgmtEpSet) != 0) { terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL; return NULL; } @@ -107,7 +107,6 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa } pObj->signature = pObj; pObj->pRpcObj = (SRpcObj *)pRpcObj; - memcpy(pObj->pRpcObj->tscCorMgmtEpSet, &corMgmtEpSet, sizeof(SRpcCorEpSet)); tstrncpy(pObj->user, user, sizeof(pObj->user)); secretEncryptLen = MIN(secretEncryptLen, sizeof(pObj->pass)); memcpy(pObj->pass, secretEncrypt, secretEncryptLen); diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index e4a1cbc7d5..41c0ae1bad 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -73,7 +73,7 @@ void tscReleaseRpc(void *param) { pthread_mutex_unlock(&rpcObjMutex); } -int32_t tscInitRpc(const char *key, const char *user, const char *secretEncrypt, void **ppRpcObj) { +int32_t tscInitRpc(const char *key, const char *user, const char *secretEncrypt, void **ppRpcObj, SRpcCorEpSet *corMgmtEpSet) { pthread_mutex_lock(&rpcObjMutex); SRpcObj *pRpcObj = (SRpcObj *)tscAcquireRpc(key); @@ -117,6 +117,7 @@ int32_t tscInitRpc(const char *key, const char *user, const char *secretEncrypt, rpcClose(rpcObj.pDnodeConn); pthread_mutex_unlock(&rpcObjMutex); } + memcpy(pRpcObj->tscCorMgmtEpSet, corMgmtEpSet, sizeof(*corMgmtEpSet)); *ppRpcObj = pRpcObj; pthread_mutex_unlock(&rpcObjMutex); -- GitLab