From 66753111c92bdb526557641f66c5385dbf3aa4f3 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 6 Aug 2024 16:52:28 +0800 Subject: [PATCH 1/2] fix return error --- source/client/src/clientEnv.c | 2 +- source/client/src/clientImpl.c | 1 + source/dnode/mgmt/node_mgmt/src/dmTransport.c | 6 +++--- source/libs/function/src/udfd.c | 2 +- source/libs/sync/test/sync_test_lib/src/syncIO.c | 4 ++-- source/libs/transport/test/cliBench.c | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 35e6651c41..530d52026f 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -375,7 +375,7 @@ int32_t openTransporter(const char *user, const char *auth, int32_t numOfThread, *pDnodeConn = rpcOpen(&rpcInit); if (*pDnodeConn == NULL) { tscError("failed to init connection to server."); - code = TSDB_CODE_FAILED; + code = terrno; } return code; diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 4aa78caa15..61579aee77 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -2467,6 +2467,7 @@ TSDB_SERVER_STATUS taos_check_server_status(const char* fqdn, int port, char* de clientRpc = rpcOpen(&rpcInit); if (clientRpc == NULL) { + code = terrno; tscError("failed to init server status client"); goto _OVER; } diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index 3d758e1fd3..30f1038a11 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -393,7 +393,7 @@ int32_t dmInitClient(SDnode *pDnode) { pTrans->clientRpc = rpcOpen(&rpcInit); if (pTrans->clientRpc == NULL) { dError("failed to init dnode rpc client"); - return -1; + return terrno; } dDebug("dnode rpc client is initialized"); @@ -437,7 +437,7 @@ int32_t dmInitStatusClient(SDnode *pDnode) { pTrans->statusRpc = rpcOpen(&rpcInit); if (pTrans->statusRpc == NULL) { dError("failed to init dnode rpc status client"); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } dDebug("dnode rpc status client is initialized"); @@ -482,7 +482,7 @@ int32_t dmInitSyncClient(SDnode *pDnode) { pTrans->syncRpc = rpcOpen(&rpcInit); if (pTrans->syncRpc == NULL) { dError("failed to init dnode rpc sync client"); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } dDebug("dnode rpc sync client is initialized"); diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 7339f115a3..f65ff79553 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -1173,7 +1173,7 @@ int32_t udfdOpenClientRpc() { global.clientRpc = rpcOpen(&rpcInit); if (global.clientRpc == NULL) { fnError("failed to init dnode rpc client"); - return -1; + return terrno; } return 0; } diff --git a/source/libs/sync/test/sync_test_lib/src/syncIO.c b/source/libs/sync/test/sync_test_lib/src/syncIO.c index 11894f7853..f5a32b98d9 100644 --- a/source/libs/sync/test/sync_test_lib/src/syncIO.c +++ b/source/libs/sync/test/sync_test_lib/src/syncIO.c @@ -193,7 +193,7 @@ static int32_t syncIOStartInternal(SSyncIO *io) { io->clientRpc = rpcOpen(&rpcInit); if (io->clientRpc == NULL) { sError("failed to initialize RPC"); - return -1; + return terrno; } } @@ -214,7 +214,7 @@ static int32_t syncIOStartInternal(SSyncIO *io) { void *pRpc = rpcOpen(&rpcInit); if (pRpc == NULL) { sError("failed to start RPC server"); - return -1; + return terrno; } } diff --git a/source/libs/transport/test/cliBench.c b/source/libs/transport/test/cliBench.c index 8a5276b814..ec08f1baf0 100644 --- a/source/libs/transport/test/cliBench.c +++ b/source/libs/transport/test/cliBench.c @@ -160,7 +160,7 @@ int main(int argc, char *argv[]) { void *pRpc = rpcOpen(&rpcInit); if (pRpc == NULL) { tError("failed to initialize RPC"); - return -1; + return terrno; } tInfo("client is initialized"); From 6905cc47ed2f6b7031aee5b187cf0b86bf38f486 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 8 Aug 2024 09:23:34 +0800 Subject: [PATCH 2/2] refactor transport code --- source/client/src/clientEnv.c | 2 +- source/client/src/clientImpl.c | 2 +- source/dnode/mgmt/node_mgmt/src/dmTransport.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 530d52026f..5eebe691ea 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -374,7 +374,7 @@ int32_t openTransporter(const char *user, const char *auth, int32_t numOfThread, *pDnodeConn = rpcOpen(&rpcInit); if (*pDnodeConn == NULL) { - tscError("failed to init connection to server."); + tscError("failed to init connection to server since %s", tstrerror(terrno)); code = terrno; } diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 61579aee77..664de5619f 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -2468,7 +2468,7 @@ TSDB_SERVER_STATUS taos_check_server_status(const char* fqdn, int port, char* de clientRpc = rpcOpen(&rpcInit); if (clientRpc == NULL) { code = terrno; - tscError("failed to init server status client"); + tscError("failed to init server status client since %s", tstrerror(code)); goto _OVER; } diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index 30f1038a11..b43a92f028 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -392,7 +392,7 @@ int32_t dmInitClient(SDnode *pDnode) { pTrans->clientRpc = rpcOpen(&rpcInit); if (pTrans->clientRpc == NULL) { - dError("failed to init dnode rpc client"); + dError("failed to init dnode rpc client since:%s", tstrerror(terrno)); return terrno; } @@ -436,7 +436,7 @@ int32_t dmInitStatusClient(SDnode *pDnode) { pTrans->statusRpc = rpcOpen(&rpcInit); if (pTrans->statusRpc == NULL) { - dError("failed to init dnode rpc status client"); + dError("failed to init dnode rpc status client since %s", tstrerror(terrno)); return terrno; } @@ -481,7 +481,7 @@ int32_t dmInitSyncClient(SDnode *pDnode) { pTrans->syncRpc = rpcOpen(&rpcInit); if (pTrans->syncRpc == NULL) { - dError("failed to init dnode rpc sync client"); + dError("failed to init dnode rpc sync client since %s", tstrerror(terrno)); return terrno; } @@ -531,7 +531,7 @@ int32_t dmInitServer(SDnode *pDnode) { (void)taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); pTrans->serverRpc = rpcOpen(&rpcInit); if (pTrans->serverRpc == NULL) { - dError("failed to init dnode rpc server"); + dError("failed to init dnode rpc server since:%s", tstrerror(terrno)); return terrno; }