From 3f726464eab393597e658a47567d7486a9962ec5 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 22 Mar 2021 11:21:53 +0000 Subject: [PATCH] TD-3246 --- CMakeLists.txt | 2 +- cmake/define.inc | 4 ++++ cmake/input.inc | 8 ++++++++ src/dnode/CMakeLists.txt | 4 ++++ src/dnode/src/dnodeMain.c | 8 ++++++++ src/inc/module.h | 30 ++++++++++++++++++++++++++++++ 6 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/inc/module.h diff --git a/CMakeLists.txt b/CMakeLists.txt index be97e679d1..0e3745db3b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ SET(TD_GRANT FALSE) SET(TD_MQTT FALSE) SET(TD_TSDB_PLUGINS FALSE) SET(TD_STORAGE FALSE) -SET(TD_TOPIC FALSE) +SET(TD_MODULE FALSE) SET(TD_COVER FALSE) SET(TD_MEM_CHECK FALSE) diff --git a/cmake/define.inc b/cmake/define.inc index ff4583d02b..6f49630d5c 100755 --- a/cmake/define.inc +++ b/cmake/define.inc @@ -29,6 +29,10 @@ IF (TD_TOPIC) ADD_DEFINITIONS(-D_TOPIC) ENDIF () +IF (TD_MODULE) + ADD_DEFINITIONS(-D_MODULE) +ENDIF () + IF (TD_GODLL) ADD_DEFINITIONS(-D_TD_GO_DLL_) ENDIF () diff --git a/cmake/input.inc b/cmake/input.inc index b1a993c996..00e0e1bc0f 100755 --- a/cmake/input.inc +++ b/cmake/input.inc @@ -17,6 +17,14 @@ ELSEIF (${TOPIC} MATCHES "false") MESSAGE(STATUS "Build without topic plugins") ENDIF () +IF (${TD_MODULE} MATCHES "true") + SET(TD_MODULE TRUE) + MESSAGE(STATUS "Build with module plugins") +ELSEIF (${TOPIC} MATCHES "false") + SET(TD_MODULE FALSE) + MESSAGE(STATUS "Build without module plugins") +ENDIF () + IF (${COVER} MATCHES "true") SET(TD_COVER TRUE) MESSAGE(STATUS "Build with test coverage") diff --git a/src/dnode/CMakeLists.txt b/src/dnode/CMakeLists.txt index 516e5b4d1f..dd18f00920 100644 --- a/src/dnode/CMakeLists.txt +++ b/src/dnode/CMakeLists.txt @@ -35,6 +35,10 @@ IF (TD_TOPIC) TARGET_LINK_LIBRARIES(taosd topic) ENDIF () +IF (TD_MODULE AND TD_LINUX) + TARGET_LINK_LIBRARIES(taosd module dl) +ENDIF () + SET(PREPARE_ENV_CMD "prepare_env_cmd") SET(PREPARE_ENV_TARGET "prepare_env_target") ADD_CUSTOM_COMMAND(OUTPUT ${PREPARE_ENV_CMD} diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index c24eac84cf..8ac712386e 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -39,6 +39,12 @@ #include "dnodeMPeer.h" #include "dnodeShell.h" #include "dnodeTelemetry.h" +#include "module.h" + +#ifndef _MODULE +int32_t moduleStart() { return 0; } +void moduleStop(); +#endif void *tsDnodeTmr = NULL; static SRunStatus tsRunStatus = TSDB_RUN_STATUS_STOPPED; @@ -146,6 +152,7 @@ int32_t dnodeInitSystem() { } dnodeSetRunStatus(TSDB_RUN_STATUS_RUNING); + moduleStart(); dnodeReportStep("TDengine", "initialized successfully", 1); dInfo("TDengine is initialized successfully"); @@ -155,6 +162,7 @@ int32_t dnodeInitSystem() { void dnodeCleanUpSystem() { if (dnodeGetRunStatus() != TSDB_RUN_STATUS_STOPPED) { + moduleStop(); dnodeSetRunStatus(TSDB_RUN_STATUS_STOPPED); dnodeCleanupTmr(); dnodeCleanupComponents(); diff --git a/src/inc/module.h b/src/inc/module.h new file mode 100644 index 0000000000..b9b64c493e --- /dev/null +++ b/src/inc/module.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_MODULE +#define TDENGINE_MODULE + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t moduleStart(); +void moduleStop(); + +#ifdef __cplusplus +} +#endif + +#endif -- GitLab