提交 31534ad1 编写于 作者: Y yihaoDeng

refactor rpc code

上级 34145487
...@@ -383,10 +383,9 @@ typedef struct SSqlStream { ...@@ -383,10 +383,9 @@ typedef struct SSqlStream {
void tscSetStreamDestTable(SSqlStream* pStream, const char* dstTable); void tscSetStreamDestTable(SSqlStream* pStream, const char* dstTable);
void *tscAcquireRpc(const char *key); int tscAcquireRpc(const char *key, const char *user, const char *secret, SRpcCorEpSet *corMgmtEpSet, void **pRpcObj);
void tscReleaseRpc(void *param); void tscReleaseRpc(void *param);
int32_t tscInitRpc(const char *key, const char *user, const char *secret, void **pRpcObj, SRpcCorEpSet *corMgmtEpSet); void tscInitMsgsFp();
void tscInitMsgsFp();
int tsParseSql(SSqlObj *pSql, bool initial); int tsParseSql(SSqlObj *pSql, bool initial);
......
...@@ -94,7 +94,7 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa ...@@ -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); sprintf(rpcKey, "%s:%s:%s:%d", user, pass, ip, port);
void *pRpcObj = NULL; void *pRpcObj = NULL;
if (tscInitRpc(rpcKey, user, secretEncrypt, &pRpcObj, &corMgmtEpSet) != 0) { if (tscAcquireRpc(rpcKey, user, secretEncrypt,&corMgmtEpSet, &pRpcObj) != 0) {
terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL; terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL;
return NULL; return NULL;
} }
......
...@@ -56,13 +56,6 @@ void tscFreeRpcObj(void *param) { ...@@ -56,13 +56,6 @@ void tscFreeRpcObj(void *param) {
rpcClose(pRpcObj->pDnodeConn); rpcClose(pRpcObj->pDnodeConn);
tfree(pRpcObj->tscCorMgmtEpSet); tfree(pRpcObj->tscCorMgmtEpSet);
} }
void *tscAcquireRpc(const char *key) {
SRpcObj *pRpcObj = taosCacheAcquireByKey(tscRpcCache, key, strlen(key));
if (pRpcObj == NULL) {
return NULL;
}
return pRpcObj;
}
void tscReleaseRpc(void *param) { void tscReleaseRpc(void *param) {
if (param == NULL) { if (param == NULL) {
...@@ -73,10 +66,10 @@ void tscReleaseRpc(void *param) { ...@@ -73,10 +66,10 @@ void tscReleaseRpc(void *param) {
pthread_mutex_unlock(&rpcObjMutex); pthread_mutex_unlock(&rpcObjMutex);
} }
int32_t tscInitRpc(const char *key, const char *user, const char *secretEncrypt, void **ppRpcObj, SRpcCorEpSet *corMgmtEpSet) { int32_t tscAcquireRpc(const char *key, const char *user, const char *secretEncrypt, SRpcCorEpSet *corMgmtEpSet, void **ppRpcObj) {
pthread_mutex_lock(&rpcObjMutex); pthread_mutex_lock(&rpcObjMutex);
SRpcObj *pRpcObj = (SRpcObj *)tscAcquireRpc(key); SRpcObj *pRpcObj = (SRpcObj *)taosCacheAcquireByKey(tscRpcCache, key, strlen(key));
if (pRpcObj != NULL) { if (pRpcObj != NULL) {
*ppRpcObj = pRpcObj; *ppRpcObj = pRpcObj;
pthread_mutex_unlock(&rpcObjMutex); pthread_mutex_unlock(&rpcObjMutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册