From 7625e803d165778ac95627ec1afec949f5264c22 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 25 Jan 2021 13:23:55 +0800 Subject: [PATCH] TD-2837 --- CMakeLists.txt | 2 +- src/balance/CMakeLists.txt | 8 +-- src/cq/CMakeLists.txt | 24 ++------ src/dnode/CMakeLists.txt | 97 +++++++++--------------------- src/mnode/CMakeLists.txt | 23 ++----- src/os/inc/osDarwin.h | 9 +-- src/plugins/http/src/httpServer.c | 19 +++--- src/plugins/monitor/CMakeLists.txt | 22 ++----- src/rpc/src/rpcTcp.c | 14 +---- src/sync/src/syncTcp.c | 8 --- src/vnode/CMakeLists.txt | 12 +--- src/wal/CMakeLists.txt | 14 +---- 12 files changed, 66 insertions(+), 186 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ac06c165d..315036d115 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ MESSAGE(STATUS "Community directory: " ${TD_COMMUNITY_DIR}) INCLUDE(cmake/input.inc) INCLUDE(cmake/platform.inc) -IF (TD_WINDOWS) +IF (TD_WINDOWS OR TD_DARWIN) SET(TD_SOMODE_STATIC TRUE) ENDIF () diff --git a/src/balance/CMakeLists.txt b/src/balance/CMakeLists.txt index 17eb34666e..bcb3769087 100644 --- a/src/balance/CMakeLists.txt +++ b/src/balance/CMakeLists.txt @@ -8,10 +8,4 @@ INCLUDE_DIRECTORIES(${TD_ENTERPRISE_DIR}/src/inc) INCLUDE_DIRECTORIES(inc) AUX_SOURCE_DIRECTORY(src SRC) -IF (TD_LINUX OR TD_WINDOWS) - ADD_LIBRARY(balance ${SRC}) -ENDIF () - -IF (TD_DARWIN) - ADD_LIBRARY(balance ${SRC}) -ENDIF () +ADD_LIBRARY(balance ${SRC}) diff --git a/src/cq/CMakeLists.txt b/src/cq/CMakeLists.txt index d5d9116074..73d5eebd6d 100644 --- a/src/cq/CMakeLists.txt +++ b/src/cq/CMakeLists.txt @@ -6,22 +6,10 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SRC) -IF (TD_LINUX OR TD_WINDOWS) - ADD_LIBRARY(tcq ${SRC}) - IF (TD_SOMODE_STATIC) - TARGET_LINK_LIBRARIES(tcq tutil common taos_static) - ELSE () - TARGET_LINK_LIBRARIES(tcq tutil common taos) - ENDIF () - ADD_SUBDIRECTORY(test) -ENDIF () - -IF (TD_DARWIN) - ADD_LIBRARY(tcq ${SRC}) - IF (TD_SOMODE_STATIC) - TARGET_LINK_LIBRARIES(tcq tutil common taos_static) - ELSE () - TARGET_LINK_LIBRARIES(tcq tutil common taos) - ENDIF () - ADD_SUBDIRECTORY(test) +ADD_LIBRARY(tcq ${SRC}) +IF (TD_SOMODE_STATIC) + TARGET_LINK_LIBRARIES(tcq tutil common taos_static) +ELSE () + TARGET_LINK_LIBRARIES(tcq tutil common taos) ENDIF () +ADD_SUBDIRECTORY(test) diff --git a/src/dnode/CMakeLists.txt b/src/dnode/CMakeLists.txt index 8e902e1114..14ec98b8f8 100644 --- a/src/dnode/CMakeLists.txt +++ b/src/dnode/CMakeLists.txt @@ -10,79 +10,38 @@ INCLUDE_DIRECTORIES(${TD_ENTERPRISE_DIR}/src/inc) INCLUDE_DIRECTORIES(inc) AUX_SOURCE_DIRECTORY(src SRC) -IF (TD_LINUX OR TD_WINDOWS) - ADD_EXECUTABLE(taosd ${SRC}) - TARGET_LINK_LIBRARIES(taosd mnode monitor http tsdb twal vnode cJson lz4 balance sync) +ADD_EXECUTABLE(taosd ${SRC}) +TARGET_LINK_LIBRARIES(taosd mnode monitor http tsdb twal vnode cJson lz4 balance sync) - IF (TD_SOMODE_STATIC) - TARGET_LINK_LIBRARIES(taosd taos_static) - ELSE () - TARGET_LINK_LIBRARIES(taosd taos) - ENDIF () - - IF (TD_ACCOUNT) - TARGET_LINK_LIBRARIES(taosd account) - ENDIF () - - IF (TD_GRANT) - TARGET_LINK_LIBRARIES(taosd grant) - ENDIF () - - IF (TD_LINUX AND TD_MQTT) - TARGET_LINK_LIBRARIES(taosd mqtt) - ENDIF () - - SET(PREPARE_ENV_CMD "prepare_env_cmd") - SET(PREPARE_ENV_TARGET "prepare_env_target") - ADD_CUSTOM_COMMAND(OUTPUT ${PREPARE_ENV_CMD} - POST_BUILD - COMMAND echo "make test directory" - DEPENDS taosd - COMMAND ${CMAKE_COMMAND} -E make_directory ${TD_TESTS_OUTPUT_DIR}/cfg/ - COMMAND ${CMAKE_COMMAND} -E make_directory ${TD_TESTS_OUTPUT_DIR}/log/ - COMMAND ${CMAKE_COMMAND} -E make_directory ${TD_TESTS_OUTPUT_DIR}/data/ - COMMAND ${CMAKE_COMMAND} -E echo dataDir ${TD_TESTS_OUTPUT_DIR}/data > ${TD_TESTS_OUTPUT_DIR}/cfg/taos.cfg - COMMAND ${CMAKE_COMMAND} -E echo logDir ${TD_TESTS_OUTPUT_DIR}/log >> ${TD_TESTS_OUTPUT_DIR}/cfg/taos.cfg - COMMAND ${CMAKE_COMMAND} -E echo charset UTF-8 >> ${TD_TESTS_OUTPUT_DIR}/cfg/taos.cfg - COMMENT "prepare taosd environment") - ADD_CUSTOM_TARGET(${PREPARE_ENV_TARGET} ALL WORKING_DIRECTORY ${TD_EXECUTABLE_OUTPUT_PATH} DEPENDS ${PREPARE_ENV_CMD}) +IF (TD_SOMODE_STATIC) + TARGET_LINK_LIBRARIES(taosd taos_static) +ELSE () + TARGET_LINK_LIBRARIES(taosd taos) ENDIF () -IF (TD_DARWIN) - ADD_EXECUTABLE(taosd ${SRC}) - TARGET_LINK_LIBRARIES(taosd mnode monitor http tsdb twal vnode cJson lz4 balance sync) - - IF (TD_SOMODE_STATIC) - TARGET_LINK_LIBRARIES(taosd taos_static) - ELSE () - TARGET_LINK_LIBRARIES(taosd taos) - ENDIF () - - IF (TD_ACCOUNT) - TARGET_LINK_LIBRARIES(taosd account) - ENDIF () - - IF (TD_GRANT) - TARGET_LINK_LIBRARIES(taosd grant) - ENDIF () +IF (TD_ACCOUNT) + TARGET_LINK_LIBRARIES(taosd account) +ENDIF () - IF (TD_MQTT) - TARGET_LINK_LIBRARIES(taosd mqtt) - ENDIF () +IF (TD_GRANT) + TARGET_LINK_LIBRARIES(taosd grant) +ENDIF () - # SET(PREPARE_ENV_CMD "prepare_env_cmd") - # SET(PREPARE_ENV_TARGET "prepare_env_target") - # ADD_CUSTOM_COMMAND(OUTPUT ${PREPARE_ENV_CMD} - # POST_BUILD - # COMMAND echo "make test directory" - # DEPENDS taosd - # COMMAND ${CMAKE_COMMAND} -E make_directory ${TD_TESTS_OUTPUT_DIR}/cfg/ - # COMMAND ${CMAKE_COMMAND} -E make_directory ${TD_TESTS_OUTPUT_DIR}/log/ - # COMMAND ${CMAKE_COMMAND} -E make_directory ${TD_TESTS_OUTPUT_DIR}/data/ - # COMMAND ${CMAKE_COMMAND} -E echo dataDir ${TD_TESTS_OUTPUT_DIR}/data > ${TD_TESTS_OUTPUT_DIR}/cfg/taos.cfg - # COMMAND ${CMAKE_COMMAND} -E echo logDir ${TD_TESTS_OUTPUT_DIR}/log >> ${TD_TESTS_OUTPUT_DIR}/cfg/taos.cfg - # COMMAND ${CMAKE_COMMAND} -E echo charset UTF-8 >> ${TD_TESTS_OUTPUT_DIR}/cfg/taos.cfg - # COMMENT "prepare taosd environment") - # ADD_CUSTOM_TARGET(${PREPARE_ENV_TARGET} ALL WORKING_DIRECTORY ${TD_EXECUTABLE_OUTPUT_PATH} DEPENDS ${PREPARE_ENV_CMD}) +IF ((TD_LINUX OR TD_WINDOWS) AND TD_MQTT) + TARGET_LINK_LIBRARIES(taosd mqtt) ENDIF () +SET(PREPARE_ENV_CMD "prepare_env_cmd") +SET(PREPARE_ENV_TARGET "prepare_env_target") +ADD_CUSTOM_COMMAND(OUTPUT ${PREPARE_ENV_CMD} + POST_BUILD + COMMAND echo "make test directory" + DEPENDS taosd + COMMAND ${CMAKE_COMMAND} -E make_directory ${TD_TESTS_OUTPUT_DIR}/cfg/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${TD_TESTS_OUTPUT_DIR}/log/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${TD_TESTS_OUTPUT_DIR}/data/ + COMMAND ${CMAKE_COMMAND} -E echo dataDir ${TD_TESTS_OUTPUT_DIR}/data > ${TD_TESTS_OUTPUT_DIR}/cfg/taos.cfg + COMMAND ${CMAKE_COMMAND} -E echo logDir ${TD_TESTS_OUTPUT_DIR}/log >> ${TD_TESTS_OUTPUT_DIR}/cfg/taos.cfg + COMMAND ${CMAKE_COMMAND} -E echo charset UTF-8 >> ${TD_TESTS_OUTPUT_DIR}/cfg/taos.cfg + COMMENT "prepare taosd environment") +ADD_CUSTOM_TARGET(${PREPARE_ENV_TARGET} ALL WORKING_DIRECTORY ${TD_EXECUTABLE_OUTPUT_PATH} DEPENDS ${PREPARE_ENV_CMD}) diff --git a/src/mnode/CMakeLists.txt b/src/mnode/CMakeLists.txt index 7b25b1bec8..fffc82c6ef 100644 --- a/src/mnode/CMakeLists.txt +++ b/src/mnode/CMakeLists.txt @@ -1,23 +1,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(TDengine) -IF (TD_LINUX OR TD_WINDOWS) - INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) - INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/dnode/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) +INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/dnode/inc) - INCLUDE_DIRECTORIES(inc) - AUX_SOURCE_DIRECTORY(src SRC) - - ADD_LIBRARY(mnode ${SRC}) -ENDIF () - -IF (TD_DARWIN) - INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) - INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/dnode/inc) - - INCLUDE_DIRECTORIES(inc) - AUX_SOURCE_DIRECTORY(src SRC) - - ADD_LIBRARY(mnode ${SRC}) -ENDIF () +INCLUDE_DIRECTORIES(inc) +AUX_SOURCE_DIRECTORY(src SRC) +ADD_LIBRARY(mnode ${SRC}) diff --git a/src/os/inc/osDarwin.h b/src/os/inc/osDarwin.h index 0a77ed6895..13f93456f2 100644 --- a/src/os/inc/osDarwin.h +++ b/src/os/inc/osDarwin.h @@ -106,10 +106,11 @@ int64_t tsosStr2int64(char *str); void taos_block_sigalrm(void); - - - - +#define TAOS_OS_DEF_EPOLL + #define TAOS_EPOLL_WAIT_TIME 500 + typedef int32_t SOCKET; + typedef SOCKET EpollFd; + #define EpollClose(pollFd) epoll_close(pollFd) #ifdef __cplusplus } diff --git a/src/plugins/http/src/httpServer.c b/src/plugins/http/src/httpServer.c index a0e5bede5a..a5f40fdc4c 100644 --- a/src/plugins/http/src/httpServer.c +++ b/src/plugins/http/src/httpServer.c @@ -48,7 +48,7 @@ static void httpStopThread(HttpThread *pThread) { pThread->stop = true; r = epoll_ctl(pThread->pollFd, EPOLL_CTL_ADD, sv[0], &ev); if (r) break; - if (1!=send(sv[1], "1", 1, 0)) { + if (1 != send(sv[1], "1", 1, 0)) { r = -1; break; } @@ -56,7 +56,7 @@ static void httpStopThread(HttpThread *pThread) { if (r) { pthread_cancel(pThread->thread); } -#else +#else struct epoll_event event = {.events = EPOLLIN}; eventfd_t fd = eventfd(1, 0); if (fd == -1) { @@ -69,29 +69,26 @@ static void httpStopThread(HttpThread *pThread) { pThread->label, strerror(errno)); pthread_cancel(pThread->thread); } -#endif // __APPLE__ +#endif // __APPLE__ pthread_join(pThread->thread, NULL); + #ifdef __APPLE__ - if (sv[0]!=-1) { + if (sv[0] != -1) { close(sv[0]); sv[0] = -1; } - if (sv[1]!=-1) { + if (sv[1] != -1) { close(sv[1]); sv[1] = -1; } -#else // __APPLE__ +#else // __APPLE__ if (fd != -1) { taosCloseSocket(fd); } -#endif // __APPLE__ +#endif // __APPLE__ -#ifdef __APPLE__ - epoll_close(pThread->pollFd); -#else EpollClose(pThread->pollFd); -#endif pthread_mutex_destroy(&(pThread->threadMutex)); } diff --git a/src/plugins/monitor/CMakeLists.txt b/src/plugins/monitor/CMakeLists.txt index 0e0bc19736..abab07e0cd 100644 --- a/src/plugins/monitor/CMakeLists.txt +++ b/src/plugins/monitor/CMakeLists.txt @@ -6,22 +6,10 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) AUX_SOURCE_DIRECTORY(./src SRC) -IF (TD_LINUX OR TD_WINDOWS) - ADD_LIBRARY(monitor ${SRC}) +ADD_LIBRARY(monitor ${SRC}) - IF (TD_SOMODE_STATIC) - TARGET_LINK_LIBRARIES(monitor taos_static) - ELSE () - TARGET_LINK_LIBRARIES(monitor taos) - ENDIF () -ENDIF () - -IF (TD_DARWIN) - ADD_LIBRARY(monitor ${SRC}) - - IF (TD_SOMODE_STATIC) - TARGET_LINK_LIBRARIES(monitor taos_static) - ELSE () - TARGET_LINK_LIBRARIES(monitor taos) - ENDIF () +IF (TD_SOMODE_STATIC) + TARGET_LINK_LIBRARIES(monitor taos_static) +ELSE () + TARGET_LINK_LIBRARIES(monitor taos) ENDIF () diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index cb8611bdfb..4fe41b1709 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -314,14 +314,8 @@ void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void * int code = pthread_create(&(pThreadObj->thread), &thattr, taosProcessTcpData, (void *)(pThreadObj)); pthread_attr_destroy(&thattr); if (code != 0) { -#ifdef __APPLE__ - if (pThreadObj->pollFd!=-1) { - epoll_close(pThreadObj->pollFd); - pThreadObj->pollFd = -1; - } -#else // __APPLE__ EpollClose(pThreadObj->pollFd); -#endif // __APPLE__ + pThreadObj->pollFd = -1; free(pThreadObj); terrno = TAOS_SYSTEM_ERROR(errno); tError("%s failed to create TCP read data thread(%s)", label, strerror(errno)); @@ -529,14 +523,10 @@ static void *taosProcessTcpData(void *param) { if (pThreadObj->stop) break; } -#ifdef __APPLE__ if (pThreadObj->pollFd >=0) { - epoll_close(pThreadObj->pollFd); + EpollClose(pThreadObj->pollFd); pThreadObj->pollFd = -1; } -#else // __APPLE__ - if (pThreadObj->pollFd >=0) EpollClose(pThreadObj->pollFd); -#endif while (pThreadObj->pHead) { SFdObj *pFdObj = pThreadObj->pHead; diff --git a/src/sync/src/syncTcp.c b/src/sync/src/syncTcp.c index fb3a016791..22bdc7e74e 100644 --- a/src/sync/src/syncTcp.c +++ b/src/sync/src/syncTcp.c @@ -241,11 +241,7 @@ static void *syncProcessTcpData(void *param) { sDebug("%p TCP epoll thread exits", pThread); -#ifdef __APPLE__ - epoll_close(pThread->pollFd); -#else // __APPLE__ EpollClose(pThread->pollFd); -#endif // __APPLE__ tfree(pThread); tfree(buffer); return NULL; @@ -307,11 +303,7 @@ static SThreadObj *syncGetTcpThread(SPoolObj *pPool) { pthread_attr_destroy(&thattr); if (ret != 0) { -#ifdef __APPLE__ - epoll_close(pThread->pollFd); -#else // __APPLE__ EpollClose(pThread->pollFd); -#endif tfree(pThread); return NULL; } diff --git a/src/vnode/CMakeLists.txt b/src/vnode/CMakeLists.txt index 07106598a9..5d77d48ebf 100644 --- a/src/vnode/CMakeLists.txt +++ b/src/vnode/CMakeLists.txt @@ -10,13 +10,5 @@ INCLUDE_DIRECTORIES(${TD_ENTERPRISE_DIR}/src/inc) INCLUDE_DIRECTORIES(inc) AUX_SOURCE_DIRECTORY(src SRC) -IF (TD_LINUX OR TD_WINDOWS) - ADD_LIBRARY(vnode ${SRC}) - TARGET_LINK_LIBRARIES(vnode tsdb tcq) -ENDIF () - -IF (TD_DARWIN) - ADD_LIBRARY(vnode ${SRC}) - TARGET_LINK_LIBRARIES(vnode tsdb tcq) -ENDIF () - +ADD_LIBRARY(vnode ${SRC}) +TARGET_LINK_LIBRARIES(vnode tsdb tcq) diff --git a/src/wal/CMakeLists.txt b/src/wal/CMakeLists.txt index e77d3cd329..6f35cb9ba7 100644 --- a/src/wal/CMakeLists.txt +++ b/src/wal/CMakeLists.txt @@ -4,14 +4,6 @@ PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SRC) -IF (TD_LINUX OR TD_WINDOWS) - ADD_LIBRARY(twal ${SRC}) - TARGET_LINK_LIBRARIES(twal tutil common) - ADD_SUBDIRECTORY(test) -ENDIF () - -IF (TD_DARWIN) - ADD_LIBRARY(twal ${SRC}) - TARGET_LINK_LIBRARIES(twal tutil common) - ADD_SUBDIRECTORY(test) -ENDIF () +ADD_LIBRARY(twal ${SRC}) +TARGET_LINK_LIBRARIES(twal tutil common) +ADD_SUBDIRECTORY(test) -- GitLab