From 2bdccc20ae1c911c8eff44e87e2c0d52ab48d684 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 11 Nov 2021 18:45:25 +0800 Subject: [PATCH] minor changes --- include/dnode/mnode/sdb/sdb.h | 4 +-- source/dnode/mnode/impl/inc/mnodeInt.h | 2 +- source/dnode/mnode/impl/src/mnode.c | 2 +- source/dnode/mnode/impl/src/mnodeAcct.c | 20 +++++++-------- source/dnode/mnode/impl/src/mnodeUser.c | 18 ++++++------- source/dnode/mnode/sdb/inc/sdbInt.h | 11 ++++---- source/dnode/mnode/sdb/src/sdb.c | 25 ++++++++++--------- .../mnode/transaction/src/{trnInt.c => trn.c} | 4 +-- .../transaction/src/{trnMain.c => trnExec.c} | 0 9 files changed, 43 insertions(+), 43 deletions(-) rename source/dnode/mnode/transaction/src/{trnInt.c => trn.c} (99%) rename source/dnode/mnode/transaction/src/{trnMain.c => trnExec.c} (100%) diff --git a/include/dnode/mnode/sdb/sdb.h b/include/dnode/mnode/sdb/sdb.h index eef79fbc09..f58cbdfc56 100644 --- a/include/dnode/mnode/sdb/sdb.h +++ b/include/dnode/mnode/sdb/sdb.h @@ -121,11 +121,11 @@ typedef struct { SdbInsertFp insertFp; SdbUpdateFp updateFp; SdbDeleteFp deleteFp; -} SSdbDesc; +} SSdbHandle; int32_t sdbInit(); void sdbCleanup(); -void sdbSetHandler(SSdbDesc desc); +void sdbSetHandle(SSdbHandle handle); int32_t sdbRead(); int32_t sdbWrite(SSdbRaw *pRaw); diff --git a/source/dnode/mnode/impl/inc/mnodeInt.h b/source/dnode/mnode/impl/inc/mnodeInt.h index 95f0acf52f..96803ba4a5 100644 --- a/source/dnode/mnode/impl/inc/mnodeInt.h +++ b/source/dnode/mnode/impl/inc/mnodeInt.h @@ -24,7 +24,7 @@ extern "C" { #endif -typedef void (*MnodeRpcFp[TSDB_MSG_TYPE_MAX])(SMnodeMsg *pMsg); +typedef void (*MnodeRpcFp)(SMnodeMsg *pMsg); tmr_h mnodeGetTimer(); int32_t mnodeGetDnodeId(); diff --git a/source/dnode/mnode/impl/src/mnode.c b/source/dnode/mnode/impl/src/mnode.c index 93cd85a888..21db85fcfa 100644 --- a/source/dnode/mnode/impl/src/mnode.c +++ b/source/dnode/mnode/impl/src/mnode.c @@ -42,7 +42,7 @@ static struct { SSteps *pInitSteps; SSteps *pStartSteps; SMnodePara para; - MnodeRpcFp msgFp; + MnodeRpcFp msgFp[TSDB_MSG_TYPE_MAX]; } tsMint; int32_t mnodeGetDnodeId() { return tsMint.para.dnodeId; } diff --git a/source/dnode/mnode/impl/src/mnodeAcct.c b/source/dnode/mnode/impl/src/mnodeAcct.c index 251fcf3edc..8979ca2689 100644 --- a/source/dnode/mnode/impl/src/mnodeAcct.c +++ b/source/dnode/mnode/impl/src/mnodeAcct.c @@ -106,7 +106,7 @@ static int32_t mnodeCreateDefaultAcct() { .accessState = TSDB_VN_ALL_ACCCESS}; SSdbRaw *pRaw = mnodeAcctActionEncode(&acctObj); - if (pRaw != NULL) { + if (pRaw == NULL) { return -1; } @@ -114,15 +114,15 @@ static int32_t mnodeCreateDefaultAcct() { } int32_t mnodeInitAcct() { - SSdbDesc desc = {.sdbType = SDB_ACCT, - .keyType = SDB_KEY_BINARY, - .deployFp = (SdbDeployFp)mnodeCreateDefaultAcct, - .encodeFp = (SdbEncodeFp)mnodeAcctActionEncode, - .decodeFp = (SdbDecodeFp)mnodeAcctActionDecode, - .insertFp = (SdbInsertFp)mnodeAcctActionInsert, - .updateFp = (SdbUpdateFp)mnodeAcctActionUpdate, - .deleteFp = (SdbDeleteFp)mnodeAcctActionDelete}; - sdbSetHandler(desc); + SSdbHandle handle = {.sdbType = SDB_ACCT, + .keyType = SDB_KEY_BINARY, + .deployFp = (SdbDeployFp)mnodeCreateDefaultAcct, + .encodeFp = (SdbEncodeFp)mnodeAcctActionEncode, + .decodeFp = (SdbDecodeFp)mnodeAcctActionDecode, + .insertFp = (SdbInsertFp)mnodeAcctActionInsert, + .updateFp = (SdbUpdateFp)mnodeAcctActionUpdate, + .deleteFp = (SdbDeleteFp)mnodeAcctActionDelete}; + sdbSetHandle(handle); return 0; } diff --git a/source/dnode/mnode/impl/src/mnodeUser.c b/source/dnode/mnode/impl/src/mnodeUser.c index e7b03b8372..41ea0acc31 100644 --- a/source/dnode/mnode/impl/src/mnodeUser.c +++ b/source/dnode/mnode/impl/src/mnodeUser.c @@ -234,15 +234,15 @@ static int32_t mnodeProcessCreateUserMsg(SMnodeMsg *pMsg) { } int32_t mnodeInitUser() { - SSdbDesc desc = {.sdbType = SDB_USER, - .keyType = SDB_KEY_BINARY, - .deployFp = (SdbDeployFp)mnodeCreateDefaultUsers, - .encodeFp = (SdbEncodeFp)mnodeUserActionEncode, - .decodeFp = (SdbDecodeFp)mnodeUserActionDecode, - .insertFp = (SdbInsertFp)mnodeUserActionInsert, - .updateFp = (SdbUpdateFp)mnodeUserActionUpdate, - .deleteFp = (SdbDeleteFp)mnodeUserActionDelete}; - sdbSetHandler(desc); + SSdbHandle handle = {.sdbType = SDB_USER, + .keyType = SDB_KEY_BINARY, + .deployFp = (SdbDeployFp)mnodeCreateDefaultUsers, + .encodeFp = (SdbEncodeFp)mnodeUserActionEncode, + .decodeFp = (SdbDecodeFp)mnodeUserActionDecode, + .insertFp = (SdbInsertFp)mnodeUserActionInsert, + .updateFp = (SdbUpdateFp)mnodeUserActionUpdate, + .deleteFp = (SdbDeleteFp)mnodeUserActionDelete}; + sdbSetHandle(handle); return 0; } diff --git a/source/dnode/mnode/sdb/inc/sdbInt.h b/source/dnode/mnode/sdb/inc/sdbInt.h index 3493e97ef2..222e16abe9 100644 --- a/source/dnode/mnode/sdb/inc/sdbInt.h +++ b/source/dnode/mnode/sdb/inc/sdbInt.h @@ -19,7 +19,6 @@ #include "os.h" #include "sdb.h" #include "taosmsg.h" -#include "tglobal.h" #include "thash.h" #include "tlockfree.h" #include "tlog.h" @@ -35,7 +34,7 @@ extern "C" { #define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }} #define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }} -#define SDB_MAX_SIZE (32*1024) +#define SDB_MAX_SIZE (32 * 1024) typedef struct { char *currDir; @@ -52,13 +51,13 @@ typedef struct { SdbDeployFp deployFps[SDB_MAX]; SdbEncodeFp encodeFps[SDB_MAX]; SdbDecodeFp decodeFps[SDB_MAX]; -} SSdbObj; +} SSdbMgr; typedef struct { ESdbStatus status; - int32_t refCount; - int32_t dataLen; - char *data[]; + int32_t refCount; + int32_t dataLen; + char pData[]; } SSdbRow; #ifdef __cplusplus diff --git a/source/dnode/mnode/sdb/src/sdb.c b/source/dnode/mnode/sdb/src/sdb.c index 119f614db5..b8e0e04c02 100644 --- a/source/dnode/mnode/sdb/src/sdb.c +++ b/source/dnode/mnode/sdb/src/sdb.c @@ -15,8 +15,9 @@ #define _DEFAULT_SOURCE #include "sdbInt.h" +#include "tglobal.h" -static SSdbObj tsSdb = {0}; +static SSdbMgr tsSdb = {0}; static int32_t sdbCreateDir() { if (!taosMkDir(tsSdb.currDir)) { @@ -153,7 +154,7 @@ static int32_t sdbWriteDataFile() { SSdbRow *pRow = taosHashIterate(hash, NULL); while (pRow != NULL) { if (pRow->status == SDB_STATUS_READY) continue; - SSdbRaw *pRaw = (*encodeFp)(pRow->data); + SSdbRaw *pRaw = (*encodeFp)(pRow->pData); if (pRaw != NULL) { taosWriteFile(fd, pRaw, sizeof(SSdbRaw) + pRaw->dataLen); } else { @@ -292,15 +293,15 @@ void sdbCleanup() { } } -void sdbSetHandler(SSdbDesc desc) { - ESdbType sdb = desc.sdbType; - tsSdb.keyTypes[sdb] = desc.keyType; - tsSdb.insertFps[sdb] = desc.insertFp; - tsSdb.updateFps[sdb] = desc.updateFp; - tsSdb.deleteFps[sdb] = desc.deleteFp; - tsSdb.deployFps[sdb] = desc.deployFp; - tsSdb.encodeFps[sdb] = desc.encodeFp; - tsSdb.decodeFps[sdb] = desc.decodeFp; +void sdbSetHandle(SSdbHandle handle) { + ESdbType sdb = handle.sdbType; + tsSdb.keyTypes[sdb] = handle.keyType; + tsSdb.insertFps[sdb] = handle.insertFp; + tsSdb.updateFps[sdb] = handle.updateFp; + tsSdb.deleteFps[sdb] = handle.deleteFp; + tsSdb.deployFps[sdb] = handle.deployFp; + tsSdb.encodeFps[sdb] = handle.encodeFp; + tsSdb.decodeFps[sdb] = handle.decodeFp; } #if 0 @@ -370,7 +371,7 @@ void *sdbAcquire(ESdbType sdb, void *pKey) { if (pRow->status == SDB_STATUS_READY) { atomic_add_fetch_32(&pRow->refCount, 1); - return pRow->data; + return pRow->pData; } else { terrno = -1; // todo return NULL; diff --git a/source/dnode/mnode/transaction/src/trnInt.c b/source/dnode/mnode/transaction/src/trn.c similarity index 99% rename from source/dnode/mnode/transaction/src/trnInt.c rename to source/dnode/mnode/transaction/src/trn.c index 48f6175c62..c4db404e7b 100644 --- a/source/dnode/mnode/transaction/src/trnInt.c +++ b/source/dnode/mnode/transaction/src/trn.c @@ -223,14 +223,14 @@ int32_t trnAppendUndoAction(STrans *pTrans, SEpSet *pEpSet, void *pMsg) { } int32_t trnInit() { - SSdbDesc desc = {.sdbType = SDB_TRANS, + SSdbHandle handle = {.sdbType = SDB_TRANS, .keyType = SDB_KEY_INT32, .encodeFp = (SdbEncodeFp)trnActionEncode, .decodeFp = (SdbDecodeFp)trnActionDecode, .insertFp = (SdbInsertFp)trnActionInsert, .updateFp = (SdbUpdateFp)trnActionUpdate, .deleteFp = (SdbDeleteFp)trnActionDelete}; - sdbSetHandler(desc); + sdbSetHandle(handle); return 0; } diff --git a/source/dnode/mnode/transaction/src/trnMain.c b/source/dnode/mnode/transaction/src/trnExec.c similarity index 100% rename from source/dnode/mnode/transaction/src/trnMain.c rename to source/dnode/mnode/transaction/src/trnExec.c