refactor rpc code
This commit is contained in:
parent
3414548772
commit
31534ad197
|
@ -383,10 +383,9 @@ typedef struct SSqlStream {
|
|||
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);
|
||||
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);
|
||||
|
||||
|
|
|
@ -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, &corMgmtEpSet) != 0) {
|
||||
if (tscAcquireRpc(rpcKey, user, secretEncrypt,&corMgmtEpSet, &pRpcObj) != 0) {
|
||||
terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -56,13 +56,6 @@ void tscFreeRpcObj(void *param) {
|
|||
rpcClose(pRpcObj->pDnodeConn);
|
||||
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) {
|
||||
if (param == NULL) {
|
||||
|
@ -73,10 +66,10 @@ void tscReleaseRpc(void *param) {
|
|||
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);
|
||||
|
||||
SRpcObj *pRpcObj = (SRpcObj *)tscAcquireRpc(key);
|
||||
SRpcObj *pRpcObj = (SRpcObj *)taosCacheAcquireByKey(tscRpcCache, key, strlen(key));
|
||||
if (pRpcObj != NULL) {
|
||||
*ppRpcObj = pRpcObj;
|
||||
pthread_mutex_unlock(&rpcObjMutex);
|
||||
|
|
Loading…
Reference in New Issue