From f4e648b7f91d2ae0fff10e567a7793863a0222c7 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 2 Nov 2021 14:35:04 +0800 Subject: [PATCH] minor changes --- include/common/taosmsg.h | 3 +-- source/dnode/mgmt/inc/dnodeInt.h | 2 +- source/dnode/mgmt/src/dnodeDnode.c | 15 ++++++++++----- source/dnode/mgmt/src/dnodeInt.c | 30 +++++++++++++++--------------- src/kit/shell/src/tnettest.c | 10 +++++----- 5 files changed, 32 insertions(+), 28 deletions(-) diff --git a/include/common/taosmsg.h b/include/common/taosmsg.h index c214c96f35..f9ad39fe78 100644 --- a/include/common/taosmsg.h +++ b/include/common/taosmsg.h @@ -925,8 +925,7 @@ typedef struct { int8_t reserved1[7]; char name[TSDB_STEP_NAME_LEN]; char desc[TSDB_STEP_DESC_LEN]; - char reserved2[64]; -} SStartupStep; +} SStartupMsg; // mq related typedef struct { diff --git a/source/dnode/mgmt/inc/dnodeInt.h b/source/dnode/mgmt/inc/dnodeInt.h index 1306f2d700..e3306ecfa4 100644 --- a/source/dnode/mgmt/inc/dnodeInt.h +++ b/source/dnode/mgmt/inc/dnodeInt.h @@ -42,7 +42,7 @@ void dnodeCleanup(); EDnStat dnodeGetRunStat(); void dnodeSetRunStat(); -void dnodeGetStartup(SStartupStep *); +void dnodeGetStartup(SStartupMsg *); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/src/dnodeDnode.c b/source/dnode/mgmt/src/dnodeDnode.c index 64694e9a46..701a190841 100644 --- a/source/dnode/mgmt/src/dnodeDnode.c +++ b/source/dnode/mgmt/src/dnodeDnode.c @@ -448,21 +448,26 @@ static void dnodeProcessConfigDnodeReq(SRpcMsg *pMsg) { static void dnodeProcessStartupReq(SRpcMsg *pMsg) { dInfo("startup msg is received, cont:%s", (char *)pMsg->pCont); - SStartupStep *pStep = rpcMallocCont(sizeof(SStartupStep)); - dnodeGetStartup(pStep); + SStartupMsg *pStartup = rpcMallocCont(sizeof(SStartupMsg)); + dnodeGetStartup(pStartup); - dInfo("startup msg is sent, step:%s desc:%s finished:%d", pStep->name, pStep->desc, pStep->finished); + dInfo("startup msg is sent, step:%s desc:%s finished:%d", pStartup->name, pStartup->desc, pStartup->finished); - SRpcMsg rpcRsp = {.handle = pMsg->handle, .pCont = pStep, .contLen = sizeof(SStartupStep)}; + SRpcMsg rpcRsp = {.handle = pMsg->handle, .pCont = pStartup, .contLen = sizeof(SStartupMsg)}; rpcSendResponse(&rpcRsp); rpcFreeCont(pMsg->pCont); } static void *dnodeThreadRoutine(void *param) { int32_t ms = tsStatusInterval * 1000; + while (!tsDnode.threadStop) { + if (dnodeGetRunStat() != DN_RUN_STAT_RUNNING) { + continue; + } else { + dnodeSendStatusMsg(); + } taosMsleep(ms); - dnodeSendStatusMsg(); } } diff --git a/source/dnode/mgmt/src/dnodeInt.c b/source/dnode/mgmt/src/dnodeInt.c index a1e7bc1c7e..e853ba7f14 100644 --- a/source/dnode/mgmt/src/dnodeInt.c +++ b/source/dnode/mgmt/src/dnodeInt.c @@ -26,30 +26,30 @@ #include "wal.h" static struct { - EDnStat runStatus; - SStartupStep startup; - SSteps *steps; + SStartupMsg startup; + EDnStat runStat; + SSteps *steps; } tsInt; -EDnStat dnodeGetRunStat() { return tsInt.runStatus; } +EDnStat dnodeGetRunStat() { return tsInt.runStat; } -void dnodeSetRunStat(EDnStat stat) { tsInt.runStatus = stat; } +void dnodeSetRunStat(EDnStat stat) { tsInt.runStat = stat; } static void dnodeReportStartup(char *name, char *desc) { - SStartupStep *startup = &tsInt.startup; - tstrncpy(startup->name, name, strlen(startup->name)); - tstrncpy(startup->desc, desc, strlen(startup->desc)); - startup->finished = 0; + SStartupMsg *pStartup = &tsInt.startup; + tstrncpy(pStartup->name, name, strlen(pStartup->name)); + tstrncpy(pStartup->desc, desc, strlen(pStartup->desc)); + pStartup->finished = 0; } static void dnodeReportStartupFinished(char *name, char *desc) { - SStartupStep *startup = &tsInt.startup; - tstrncpy(startup->name, name, strlen(startup->name)); - tstrncpy(startup->desc, desc, strlen(startup->desc)); - startup->finished = 1; + SStartupMsg *pStartup = &tsInt.startup; + tstrncpy(pStartup->name, name, strlen(pStartup->name)); + tstrncpy(pStartup->desc, desc, strlen(pStartup->desc)); + pStartup->finished = 1; } -void dnodeGetStartup(SStartupStep *pStep) { memcpy(pStep, &tsInt.startup, sizeof(SStartupStep)); } +void dnodeGetStartup(SStartupMsg *pStartup) { memcpy(pStartup, &tsInt.startup, sizeof(SStartupMsg)); } static int32_t dnodeCheckRunning(char *dir) { char filepath[256] = {0}; @@ -99,7 +99,7 @@ static int32_t dnodeInitDir() { } static int32_t dnodeInitMain() { - tsInt.runStatus = DN_RUN_STAT_STOPPED; + tsInt.runStat = DN_RUN_STAT_STOPPED; tscEmbedded = 1; taosIgnSIGPIPE(); taosBlockSIGPIPE(); diff --git a/src/kit/shell/src/tnettest.c b/src/kit/shell/src/tnettest.c index 2a147ee4f1..c8a6b36fc7 100644 --- a/src/kit/shell/src/tnettest.c +++ b/src/kit/shell/src/tnettest.c @@ -338,7 +338,7 @@ void *taosNetInitRpc(char *secretEncrypt, char spi) { return pRpcConn; } -static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t pktLen, char spi, SStartupStep *pStep) { +static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t pktLen, char spi, SStartupMsg *pStep) { SRpcEpSet epSet; SRpcMsg reqMsg; SRpcMsg rspMsg; @@ -374,7 +374,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p } int32_t code = 0; - if (pStep != NULL && rspMsg.pCont != NULL && rspMsg.contLen > 0 && rspMsg.contLen <= sizeof(SStartupStep)) { + if (pStep != NULL && rspMsg.pCont != NULL && rspMsg.contLen > 0 && rspMsg.contLen <= sizeof(SStartupMsg)) { memcpy(pStep, rspMsg.pCont, rspMsg.contLen); code = 1; } @@ -384,8 +384,8 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p return code; } -static int32_t taosNetParseStartup(SStartupStep *pCont) { - SStartupStep *pStep = pCont; +static int32_t taosNetParseStartup(SStartupMsg *pCont) { + SStartupMsg *pStep = pCont; uInfo("step:%s desc:%s", pStep->name, pStep->desc); if (pStep->finished) { @@ -398,7 +398,7 @@ static int32_t taosNetParseStartup(SStartupStep *pCont) { static void taosNetTestStartup(char *host, int32_t port) { uInfo("check startup, host:%s port:%d\n", host, port); - SStartupStep *pStep = malloc(sizeof(SStartupStep)); + SStartupMsg *pStep = malloc(sizeof(SStartupMsg)); while (1) { int32_t code = taosNetCheckRpc(host, port + TSDB_PORT_DNODEDNODE, 20, 0, pStep); if (code > 0) {