From 79f660a222f52cc0ab71eba65d83f312a8e12928 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 21 May 2022 12:00:56 +0800 Subject: [PATCH] refactor: adjust error codes --- include/util/taoserror.h | 7 ++++--- source/dnode/mgmt/node_mgmt/inc/dmMgmt.h | 7 +++---- source/dnode/mgmt/node_mgmt/src/dmMgmt.c | 6 ++++-- source/util/src/terror.c | 3 ++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 46ab92c990..b2e1da0692 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -40,9 +40,10 @@ int32_t* taosGetErrno(); #define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error //common & util -#define TSDB_CODE_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0001) -#define TSDB_CODE_APP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0002) -#define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0003) +#define TSDB_CODE_RSP_IN_APP TAOS_DEF_ERROR_CODE(0, 0x0001) +#define TSDB_CODE_CLEAN_AND_RSP_IN_APP TAOS_DEF_ERROR_CODE(0, 0x0002) +#define TSDB_CODE_APP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x000A) +#define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x000B) #define TSDB_CODE_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0011) #define TSDB_CODE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0011) #define TSDB_CODE_OUT_OF_SHM_MEM TAOS_DEF_ERROR_CODE(0, 0x0012) diff --git a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h index 5818b58801..52711af4f8 100644 --- a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h +++ b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h @@ -134,10 +134,9 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType nType); int32_t dmMarkWrapper(SMgmtWrapper *pWrapper); void dmReleaseWrapper(SMgmtWrapper *pWrapper); SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper); - -void dmSetStatus(SDnode *pDnode, EDndRunStatus stype); -void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg); -void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg); +void dmSetStatus(SDnode *pDnode, EDndRunStatus stype); +int32_t dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg); +int32_t dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg); // dmNodes.c int32_t dmOpenNode(SMgmtWrapper *pWrapper); diff --git a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c index 96285bbe1c..cf27d89d08 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c @@ -277,7 +277,7 @@ static void dmGetServerStartupStatus(SDnode *pDnode, SServerStatusRsp *pStatus) } } -void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg) { +int32_t dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg) { dDebug("msg:%p, net test req will be processed", pMsg); SRpcMsg rsp = {.code = 0, .info = pMsg->info}; rsp.pCont = rpcMallocCont(pMsg->contLen); @@ -287,9 +287,10 @@ void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg) { rsp.contLen = pMsg->contLen; } rpcSendResponse(&rsp); + return TSDB_CODE_RSP_IN_APP; } -void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg) { +int32_t dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg) { dDebug("msg:%p, server startup status req will be processed", pMsg); SServerStatusRsp statusRsp = {0}; dmGetServerStartupStatus(pDnode, &statusRsp); @@ -313,4 +314,5 @@ void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg) { _OVER: rpcSendResponse(&rspMsg); + return TSDB_CODE_RSP_IN_APP; } diff --git a/source/util/src/terror.c b/source/util/src/terror.c index f71e54bf7d..64052d2634 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -46,7 +46,8 @@ STaosError errors[] = { #endif //common & util -TAOS_DEFINE_ERROR(TSDB_CODE_ACTION_IN_PROGRESS, "Action in progress") +TAOS_DEFINE_ERROR(TSDB_CODE_RSP_IN_APP, "Cleanup in App") +TAOS_DEFINE_ERROR(TSDB_CODE_CLEAN_AND_RSP_IN_APP, "Cleanup and rsp in App") TAOS_DEFINE_ERROR(TSDB_CODE_APP_NOT_READY, "Database not ready") TAOS_DEFINE_ERROR(TSDB_CODE_APP_ERROR, "Database internal error") TAOS_DEFINE_ERROR(TSDB_CODE_OUT_OF_MEMORY, "Out of Memory") -- GitLab