refactor transport

This commit is contained in:
Yihao Deng 2024-07-23 05:46:08 +00:00
parent 32c0c40c4d
commit ae7d4f1f85
3 changed files with 16 additions and 10 deletions

View File

@ -435,7 +435,7 @@ bool transEpSetIsEqual2(SEpSet* a, SEpSet* b);
*/
void transThreadOnce();
void transInit();
int32_t transInit();
void transCleanup();
void transPrintEpSet(SEpSet* pEpSet);

View File

@ -34,10 +34,14 @@ static int32_t transValidLocalFqdn(const char* localFqdn, uint32_t* ip) {
return 0;
}
void* rpcOpen(const SRpcInit* pInit) {
rpcInit();
int32_t code = rpcInit();
if (code != 0) {
return NULL;
}
SRpcInfo* pRpc = taosMemoryCalloc(1, sizeof(SRpcInfo));
if (pRpc == NULL) {
// return TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
if (pInit->label) {
@ -202,10 +206,8 @@ int32_t rpcCvtErrCode(int32_t code) {
return code;
}
int32_t rpcInit() {
transInit();
return 0;
}
int32_t rpcInit() { return transInit(); }
void rpcCleanup(void) {
transCleanup();
transHttpEnvDestroy();

View File

@ -692,9 +692,13 @@ static void transDestroyEnv() {
transCloseRefMgt(transSyncMsgMgt);
}
void transInit() {
int32_t transInit() {
// init env
taosThreadOnce(&transModuleInit, transInitEnv);
int32_t code = taosThreadOnce(&transModuleInit, transInitEnv);
if (code != 0) {
code = TAOS_SYSTEM_ERROR(errno);
}
return code;
}
int32_t transGetRefMgt() { return refMgt; }