diff --git a/cmake/define.inc b/cmake/define.inc index 5d4d94ff42c73a7ca11f32f8318526bfcfe4e525..ba12df6f0c331e46f4dd24156d48363931e615c2 100755 --- a/cmake/define.inc +++ b/cmake/define.inc @@ -128,6 +128,8 @@ IF (TD_DARWIN_64) SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -Wno-missing-braces -fPIC -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG") SET(RELEASE_FLAGS "-Og") + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lz4/inc) ENDIF () IF (TD_WINDOWS) diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 1d725add214f0e96d1a60aa9b889899790a4aef1..1e59396c702dfa9c67eee09a3aed5cc6b421abf4 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -12,4 +12,8 @@ ADD_SUBDIRECTORY(MsvcLibX) IF (TD_LINUX AND TD_MQTT) ADD_SUBDIRECTORY(MQTT-C) -ENDIF () \ No newline at end of file +ENDIF () + +IF (TD_DARWIN AND TD_MQTT) + ADD_SUBDIRECTORY(MQTT-C) +ENDIF () diff --git a/packaging/tools/install_client.sh b/packaging/tools/install_client.sh index dd116e9bfb0472b661321e9af786521300ed2f74..84ca3b5131ebc807e8740eaaa1e7b0651f4b5b58 100755 --- a/packaging/tools/install_client.sh +++ b/packaging/tools/install_client.sh @@ -21,7 +21,7 @@ else cd ${script_dir} script_dir="$(pwd)" data_dir="/var/lib/taos" - log_dir="~/TDengineLog" + log_dir=~/TDengineLog fi log_link_dir="/usr/local/taos/log" diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index 831012851ad70d05080bfae161c0b925d5215ae9..0727fe2a1e9492fbed95e0b67979124796785ae2 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -24,7 +24,7 @@ data_dir="/var/lib/taos" if [ "$osType" != "Darwin" ]; then log_dir="/var/log/taos" else - log_dir="~/TDengineLog" + log_dir=~/TDengineLog fi data_link_dir="/usr/local/taos/data" @@ -178,7 +178,9 @@ function install_bin() { function install_lib() { # Remove links ${csudo} rm -f ${lib_link_dir}/libtaos.* || : - ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : + if [ "$osType" != "Darwin" ]; then + ${csudo} rm -f ${lib64_link_dir}/libtaos.* || : + fi if [ "$osType" != "Darwin" ]; then ${csudo} cp ${binary_dir}/build/lib/libtaos.so.${verNumber} ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* @@ -190,12 +192,14 @@ function install_lib() { ${csudo} ln -sf ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so fi else - ${csudo} cp ${binary_dir}/build/lib/libtaos.* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* - ${csudo} ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.1.dylib + ${csudo} cp -Rf ${binary_dir}/build/lib/libtaos.* ${install_main_dir}/driver && ${csudo} chmod 777 ${install_main_dir}/driver/* + ${csudo} ln -sf ${install_main_dir}/driver/libtaos.1.dylib ${lib_link_dir}/libtaos.1.dylib ${csudo} ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib fi - ${csudo} ldconfig + if [ "$osType" != "Darwin" ]; then + ${csudo} ldconfig + fi } function install_header() { diff --git a/src/balance/CMakeLists.txt b/src/balance/CMakeLists.txt index fdc43ea32fd8913b984005f30621a801e50c45d4..a3ae74d8254a5b39fada473b83223e027659a88d 100644 --- a/src/balance/CMakeLists.txt +++ b/src/balance/CMakeLists.txt @@ -11,3 +11,7 @@ AUX_SOURCE_DIRECTORY(src SRC) IF (TD_LINUX) ADD_LIBRARY(balance ${SRC}) ENDIF () + +IF (TD_DARWIN) + ADD_LIBRARY(balance ${SRC}) +ENDIF () diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 3f8f9d2934b27274c77e009cc1ad216d7f745077..660ad564a5cb611da4411b5f23eb494f6255c7af 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -28,6 +28,28 @@ IF (TD_LINUX) ADD_SUBDIRECTORY(tests) +ELSEIF (TD_DARWIN) + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/linux) + + # set the static lib name + ADD_LIBRARY(taos_static STATIC ${SRC}) + TARGET_LINK_LIBRARIES(taos_static common query trpc tutil pthread m) + SET_TARGET_PROPERTIES(taos_static PROPERTIES OUTPUT_NAME "taos_static") + SET_TARGET_PROPERTIES(taos_static PROPERTIES CLEAN_DIRECT_OUTPUT 1) + + # generate dynamic library (*.dylib) + ADD_LIBRARY(taos SHARED ${SRC}) + TARGET_LINK_LIBRARIES(taos common query trpc tutil pthread m) + SET_TARGET_PROPERTIES(taos PROPERTIES CLEAN_DIRECT_OUTPUT 1) + + #set version of .dylib + #VERSION dylib version + #SOVERSION dylib version + #MESSAGE(STATUS "build version ${TD_VER_NUMBER}") + SET_TARGET_PROPERTIES(taos PROPERTIES VERSION ${TD_VER_NUMBER} SOVERSION 1) + + ADD_SUBDIRECTORY(tests) + ELSEIF (TD_WINDOWS) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/jni/windows/win32) diff --git a/src/cq/CMakeLists.txt b/src/cq/CMakeLists.txt index 9da831c9c137a0551306d343dd112189816ead5b..34146241a5244db84e40c2ac4abd08d7ad0a82ab 100644 --- a/src/cq/CMakeLists.txt +++ b/src/cq/CMakeLists.txt @@ -10,7 +10,17 @@ IF (TD_LINUX) ADD_LIBRARY(tcq ${SRC}) IF (TD_SOMODE_STATIC) TARGET_LINK_LIBRARIES(tcq tutil common taos_static) - ELSE () + 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) diff --git a/src/dnode/CMakeLists.txt b/src/dnode/CMakeLists.txt index 699ca00a250866122023d8a4cd789f91bd038609..905ad9d920356828464a6bc6259418d6684dc10c 100644 --- a/src/dnode/CMakeLists.txt +++ b/src/dnode/CMakeLists.txt @@ -23,7 +23,7 @@ IF (TD_LINUX) IF (TD_ACCOUNT) TARGET_LINK_LIBRARIES(taosd account) ENDIF () - + IF (TD_GRANT) TARGET_LINK_LIBRARIES(taosd grant) ENDIF () @@ -47,3 +47,42 @@ IF (TD_LINUX) COMMENT "prepare taosd environment") ADD_CUSTOM_TARGET(${PREPARE_ENV_TARGET} ALL WORKING_DIRECTORY ${TD_EXECUTABLE_OUTPUT_PATH} DEPENDS ${PREPARE_ENV_CMD}) 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_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}) +ENDIF () + diff --git a/src/dnode/src/dnodeSystem.c b/src/dnode/src/dnodeSystem.c index a4d7e791e650352433b186bc404b2d2e11729e36..893049df2ee445a1e5f1b558b35f67a2f12853e2 100644 --- a/src/dnode/src/dnodeSystem.c +++ b/src/dnode/src/dnodeSystem.c @@ -160,7 +160,11 @@ static void signal_handler(int32_t signum, siginfo_t *sigInfo, void *context) { syslog(LOG_INFO, "Shut down signal is %d", signum); syslog(LOG_INFO, "Shutting down TDengine service..."); // clean the system. +#ifdef __APPLE__ + dInfo("shut down signal is %d, sender PID:%d", signum, sigInfo->si_pid); +#else // __APPLE__ dInfo("shut down signal is %d, sender PID:%d cmdline:%s", signum, sigInfo->si_pid, taosGetCmdlineByPID(sigInfo->si_pid)); +#endif // protect the application from receive another signal struct sigaction act = {{0}}; diff --git a/src/dnode/src/dnodeTelemetry.c b/src/dnode/src/dnodeTelemetry.c index ff9598ecc563ac48bac051027385ab188e94ce75..1f7084c3b5fc3cc98646926a0007c52ca0c7cbfe 100644 --- a/src/dnode/src/dnodeTelemetry.c +++ b/src/dnode/src/dnodeTelemetry.c @@ -236,6 +236,13 @@ static void sendTelemetryReport() { taosCloseSocket(fd); } +#ifdef __APPLE__ +static int sem_timedwait(tsem_t *sem, struct timespec *to) { + fprintf(stderr, "%s[%d]%s(): not implemented yet!\n", basename(__FILE__), __LINE__, __func__); + abort(); +} +#endif + static void* telemetryThread(void* param) { struct timespec end = {0}; clock_gettime(CLOCK_REALTIME, &end); diff --git a/src/kit/shell/CMakeLists.txt b/src/kit/shell/CMakeLists.txt index 45da99e5722968591ffccf16432a8cb84d3557ff..c4f3cc5696a1442b38d7511ff69ddd7ff557b896 100644 --- a/src/kit/shell/CMakeLists.txt +++ b/src/kit/shell/CMakeLists.txt @@ -9,14 +9,14 @@ IF (TD_LINUX) AUX_SOURCE_DIRECTORY(./src SRC) LIST(REMOVE_ITEM SRC ./src/shellWindows.c) LIST(REMOVE_ITEM SRC ./src/shellDarwin.c) - ADD_EXECUTABLE(shell ${SRC}) - + ADD_EXECUTABLE(shell ${SRC}) + IF (TD_SOMODE_STATIC) TARGET_LINK_LIBRARIES(shell taos_static) ELSE () TARGET_LINK_LIBRARIES(shell taos) ENDIF () - + SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) ELSEIF (TD_WINDOWS) LIST(APPEND SRC ./src/shellEngine.c) @@ -27,7 +27,7 @@ ELSEIF (TD_WINDOWS) IF (TD_POWER) SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME power) - ELSE () + ELSE () SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) ENDIF () ELSEIF (TD_DARWIN) @@ -37,7 +37,10 @@ ELSEIF (TD_DARWIN) LIST(APPEND SRC ./src/shellCommand.c) LIST(APPEND SRC ./src/shellImport.c) ADD_EXECUTABLE(shell ${SRC}) - TARGET_LINK_LIBRARIES(shell taos_static) + # linking with dylib + TARGET_LINK_LIBRARIES(shell taos) + # linking taos statically + # TARGET_LINK_LIBRARIES(shell taos_static) SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) ENDIF () diff --git a/src/kit/taosdemo/CMakeLists.txt b/src/kit/taosdemo/CMakeLists.txt index 91c743939c26ce9bb20e18dd1f701f6eb75fd573..f74dbc2de4c045e209fe0510207d1f38a89d7a6c 100644 --- a/src/kit/taosdemo/CMakeLists.txt +++ b/src/kit/taosdemo/CMakeLists.txt @@ -7,7 +7,7 @@ INCLUDE_DIRECTORIES(inc) IF (TD_LINUX) AUX_SOURCE_DIRECTORY(. SRC) ADD_EXECUTABLE(taosdemo ${SRC}) - + IF (TD_SOMODE_STATIC) TARGET_LINK_LIBRARIES(taosdemo taos_static) ELSE () @@ -17,4 +17,13 @@ ELSEIF (TD_WINDOWS) AUX_SOURCE_DIRECTORY(. SRC) ADD_EXECUTABLE(taosdemo ${SRC}) TARGET_LINK_LIBRARIES(taosdemo taos_static) +ELSEIF (TD_DARWIN) + AUX_SOURCE_DIRECTORY(. SRC) + ADD_EXECUTABLE(taosdemo ${SRC}) + + IF (TD_SOMODE_STATIC) + TARGET_LINK_LIBRARIES(taosdemo taos_static) + ELSE () + TARGET_LINK_LIBRARIES(taosdemo taos) + ENDIF () ENDIF () diff --git a/src/kit/taosdemox/CMakeLists.txt b/src/kit/taosdemox/CMakeLists.txt index 7db6c04b281aa6dea3e9b51fc47a8796fd64371b..3993cb0feb749d4bb2d762f203baeb920f8db495 100644 --- a/src/kit/taosdemox/CMakeLists.txt +++ b/src/kit/taosdemox/CMakeLists.txt @@ -4,22 +4,44 @@ PROJECT(TDengine) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/libcurl/include) -IF (TD_LINUX) +IF (TD_LINUX) AUX_SOURCE_DIRECTORY(. SRC) ADD_EXECUTABLE(taosdemox ${SRC}) - - #find_program(HAVE_CURL NAMES curl) - IF ((NOT TD_ARM_64) AND (NOT TD_ARM_32)) + + #find_program(HAVE_CURL NAMES curl) + IF ((NOT TD_ARM_64) AND (NOT TD_ARM_32)) ADD_DEFINITIONS(-DTD_LOWA_CURL) LINK_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/libcurl/lib) ADD_LIBRARY(curl STATIC IMPORTED) SET_PROPERTY(TARGET curl PROPERTY IMPORTED_LOCATION ${TD_COMMUNITY_DIR}/deps/libcurl/lib/libcurl.a) - TARGET_LINK_LIBRARIES(taosdemox curl) + TARGET_LINK_LIBRARIES(taosdemox curl) ENDIF () - + IF (TD_SOMODE_STATIC) TARGET_LINK_LIBRARIES(taosdemox taos_static cJson) ELSE () TARGET_LINK_LIBRARIES(taosdemox taos cJson) ENDIF () ENDIF () + +IF (TD_DARWIN) + # missing a few dependencies, such as + # AUX_SOURCE_DIRECTORY(. SRC) + # ADD_EXECUTABLE(taosdemox ${SRC}) + # + # #find_program(HAVE_CURL NAMES curl) + # IF ((NOT TD_ARM_64) AND (NOT TD_ARM_32)) + # ADD_DEFINITIONS(-DTD_LOWA_CURL) + # LINK_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/libcurl/lib) + # ADD_LIBRARY(curl STATIC IMPORTED) + # SET_PROPERTY(TARGET curl PROPERTY IMPORTED_LOCATION ${TD_COMMUNITY_DIR}/deps/libcurl/lib/libcurl.a) + # TARGET_LINK_LIBRARIES(taosdemox curl) + # ENDIF () + # + # IF (TD_SOMODE_STATIC) + # TARGET_LINK_LIBRARIES(taosdemox taos_static cJson) + # ELSE () + # TARGET_LINK_LIBRARIES(taosdemox taos cJson) + # ENDIF () +ENDIF () + diff --git a/src/kit/taosdump/CMakeLists.txt b/src/kit/taosdump/CMakeLists.txt index dc9ac6d4a789c4292480f522240690e13b47245b..b50ad85c08cf5fa35862ce42bcc441dc502c3166 100644 --- a/src/kit/taosdump/CMakeLists.txt +++ b/src/kit/taosdump/CMakeLists.txt @@ -12,5 +12,15 @@ IF (TD_LINUX) TARGET_LINK_LIBRARIES(taosdump taos_static) ELSE () TARGET_LINK_LIBRARIES(taosdump taos) - ENDIF () + ENDIF () +ENDIF () + +IF (TD_DARWIN) + # missing for macosx + # ADD_EXECUTABLE(taosdump ${SRC}) + # IF (TD_SOMODE_STATIC) + # TARGET_LINK_LIBRARIES(taosdump taos_static) + # ELSE () + # TARGET_LINK_LIBRARIES(taosdump taos) + # ENDIF () ENDIF () diff --git a/src/mnode/CMakeLists.txt b/src/mnode/CMakeLists.txt index 41230986948c7ddbd746e2bd2c6e5fcece66c041..ae4a37320c301a5bebf5e95b2c5dd2aec216d096 100644 --- a/src/mnode/CMakeLists.txt +++ b/src/mnode/CMakeLists.txt @@ -9,4 +9,15 @@ IF (TD_LINUX) AUX_SOURCE_DIRECTORY(src SRC) ADD_LIBRARY(mnode ${SRC}) -ENDIF () \ No newline at end of file +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 () + diff --git a/src/mnode/src/mnodeCluster.c b/src/mnode/src/mnodeCluster.c index a35e30481077d0e16888d0ee036312cd068ea9b4..08bf20e1a8a370a1799960f8640f3dace12cbf22 100644 --- a/src/mnode/src/mnodeCluster.c +++ b/src/mnode/src/mnodeCluster.c @@ -138,6 +138,13 @@ void mnodeDecClusterRef(SClusterObj *pCluster) { sdbDecRef(tsClusterSdb, pCluster); } +#ifdef __APPLE__ +bool taosGetSystemUid(char *uid) { + fprintf(stderr, "%s[%d]%s(): not implemented yet!\n", basename(__FILE__), __LINE__, __func__); + abort(); + return false; +} +#endif // __APPLE__ static int32_t mnodeCreateCluster() { int32_t numOfClusters = sdbGetNumOfRows(tsClusterSdb); if (numOfClusters != 0) return TSDB_CODE_SUCCESS; diff --git a/src/os/src/darwin/eok.c b/src/os/src/darwin/eok.c index a6dceb3df384244bbf61872c3210b20584550704..1be5ec4ac13c0ca690ee3b5a5358b20dd3b36260 100644 --- a/src/os/src/darwin/eok.c +++ b/src/os/src/darwin/eok.c @@ -103,9 +103,9 @@ struct eok_event_s { typedef struct eoks_s eoks_t; struct eoks_s { pthread_mutex_t lock; - ep_over_kq_t *eoks; - int neoks; - ep_over_kq_t *eoks_free; + ep_over_kq_t **eoks; // note: this memory leaks when process terminates + int neoks; // we can add an extra api to let user clean + ep_over_kq_t *eoks_free; // currently, we just keep it simple stupid }; static eoks_t eoks = { @@ -297,7 +297,7 @@ int epoll_create(int size) { struct epoll_event ev = {0}; ev.events = EPOLLIN; ev.data.ptr = &eok_dummy; - D("epoll_create epfd:[%d]", eok->idx); + D("epoll_create epfd:[%d] and sv0[%d]", eok->idx, eok->sv[0]); if (epoll_ctl(eok->idx, EPOLL_CTL_ADD, eok->sv[0], &ev)) { e = errno; epoll_close(eok->idx); @@ -517,8 +517,8 @@ int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) eok_event_t *ev = (eok_event_t*)kev->udata; A(kev->ident == ev->fd, "internal logic error"); if (kev->flags & EV_ERROR) { - D("error when processing change list for fd[%d], error[%s], kev_flags:[%04x:%s]", - ev->fd, strerror(kev->data), kev->flags, kev_flags_str(kev->flags, 0)); + D("epfd[%d] error when processing change list for fd[%d], error[%s], kev_flags:[%04x:%s]", + epfd, ev->fd, strerror(kev->data), kev->flags, kev_flags_str(kev->flags, 0)); } switch (kev->filter) { case EVFILT_READ: { @@ -528,11 +528,11 @@ int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) char c = '\0'; A(1==recv(kev->ident, &c, 1, 0), "internal logic error"); A(0==memcmp(&c, "1", 1), "internal logic error"); - D("wokenup"); + D("epfd[%d] wokenup", epfd); continue; } else { if (ev->changed==3) { - D("already requested to delete for fd[%d]", ev->fd); + D("epfd[%d] already requested to delete for fd[%d]", epfd, ev->fd); // TODO: write a unit test for this case // EV_DELETE? continue; @@ -550,7 +550,8 @@ int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) } // rounded to what user care pev.events = pev.events & ev->epev.events; - D("events found for fd[%d]: [%04x:%s], which was registered: [%04x:%s], kev_flags: [%04x:%s]", + D("epfd[%d] events found for fd[%d]: [%04x:%s], which was registered: [%04x:%s], kev_flags: [%04x:%s]", + epfd, ev->fd, pev.events, events_str(pev.events, 0), ev->epev.events, events_str(ev->epev.events, 1), kev->flags, kev_flags_str(kev->flags, 2)); @@ -573,7 +574,7 @@ int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) while (p) { eok_event_t *next = p->next; if (p->changed==3) { - D("removing registered event for fd[%d]: [%04x:%s]", p->fd, p->epev.events, events_str(p->epev.events, 0)); + D("epfd[%d] removing registered event for fd[%d]: [%04x:%s]", epfd, p->fd, p->epev.events, events_str(p->epev.events, 0)); eok_free_ev(eok, p); } p = next; @@ -591,13 +592,13 @@ int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) } } while (cnts==0); if (cnts>0) { - D("kevent64 waiting done with [%d] events", cnts); + D("kevent64 epfd[%d] waiting done with [%d] events", epfd, cnts); } A(0==pthread_mutex_unlock(&eok->lock), ""); if (e) { errno = e; - E("epoll_wait failed"); + E("epfd[%d] epoll_wait failed", epfd); return -1; } @@ -752,7 +753,7 @@ static int eok_chgs_refresh(ep_over_kq_t *eok, eok_event_t *oev, eok_event_t *ev eok->kchanges[eok->ichanges++] = *kwev; ++n; } - D("add #changes[%d] for fd[%d], and now #changes/registers [%d/%d]", n, ev->fd, eok->ichanges, eok->evs_count); + D("epfd[%d]: add #changes[%d] for fd[%d], and now #changes/registers [%d/%d]", eok->idx, n, ev->fd, eok->ichanges, eok->evs_count); return 0; } @@ -764,14 +765,21 @@ static ep_over_kq_t* eoks_alloc(void) { if (eoks.eoks_free) { eok = eoks.eoks_free; eoks.eoks_free = eok->next; + A(eoks.eoks, "internal logic error"); + A(eok->idx>=0 && eok->idxidx)==NULL, "internal logic error"); + *(eoks.eoks + eok->idx) = eok; eok->next = NULL; + eok->stopping = 0; break; } - ep_over_kq_t *p = (ep_over_kq_t*)realloc(eoks.eoks, sizeof(*p) * (eoks.neoks+1)); - if (!p) break; - eoks.eoks = p; - eok = eoks.eoks + eoks.neoks; - memset(eok, 0, sizeof(*eok)); + eok = (ep_over_kq_t*)calloc(1, sizeof(*eok)); + if (!eok) break; + eok->idx = -1; + ep_over_kq_t **ar = (ep_over_kq_t**)realloc(eoks.eoks, sizeof(**ar) * (eoks.neoks+1)); + if (!ar) break; + eoks.eoks = ar; + *(eoks.eoks + eoks.neoks) = eok; eok->idx = eoks.neoks; eok->kq = -1; eok->sv[0] = -1; @@ -784,6 +792,11 @@ static ep_over_kq_t* eoks_alloc(void) { errno = ENOMEM; return NULL; } + if (eok->idx==-1) { + free(eok); + errno = ENOMEM; + return NULL; + } if (eok->lock_valid) { return eok; } @@ -801,23 +814,50 @@ static ep_over_kq_t* eoks_alloc(void) { static void eoks_free(ep_over_kq_t *eok) { A(0==pthread_mutex_lock(&eoks.lock), ""); do { + A(eok->idx>=0 && eok->idxnext==NULL, "internal logic error"); // leave eok->kchanges as is A(eok->ichanges==0, "internal logic error"); A(eok->waiting==0, "internal logic error"); - if (eok->evs_count==1) { - A(eok->evs_head && eok->evs_tail && eok->evs_head==eok->evs_tail, "internal logic error"); - A(eok->evs_head->fd==eok->sv[0] && eok->sv[0]!=-1 && eok->sv[1]!=-1, "internal logic error"); - // fd is critical system resource - close(eok->sv[0]); - eok->sv[0] = -1; - close(eok->sv[1]); - eok->sv[1] = -1; - eok_free_ev(eok, eok->evs_head); + eok_event_t *ev = eok->evs_head; + while (ev) { + eok_event_t *next = ev->next; + if (ev->fd==eok->sv[0]) { + // fd is critical system resource + close(eok->sv[0]); + eok->sv[0] = -1; + close(eok->sv[1]); + eok->sv[1] = -1; + eok_free_ev(eok, ev); + } else { + // user forget calling epoll_ctl(EPOLL_CTL_DEL) before calling epoll_close/close? + // calling close(ev->fd) here smells really bad +#ifdef LET_IT_BE + // we just let it be and reclaim ev + eok_free_ev(eok, ev); +#else + // panic otherwise, if LET_IT_BE not defined + A(eok->evs_head==NULL && eok->evs_tail==NULL && eok->evs_count==0, + "epfd[%d] fd[%d]: internal logic error: have you epoll_ctl(EPOLL_CTL_DEL) everything before calling epoll_close?", + eok->idx, ev->fd); +#endif + } + ev = next; } - A(eok->evs_head==NULL && eok->evs_tail==NULL && eok->evs_count==0, "internal logic error"); + // if (eok->evs_count==1) { + // A(eok->evs_head && eok->evs_tail && eok->evs_head==eok->evs_tail, "internal logic error"); + // A(eok->evs_head->fd==eok->sv[0] && eok->sv[0]!=-1 && eok->sv[1]!=-1, "internal logic error"); + // // fd is critical system resource + // close(eok->sv[0]); + // eok->sv[0] = -1; + // close(eok->sv[1]); + // eok->sv[1] = -1; + // eok_free_ev(eok, eok->evs_head); + // } + A(eok->evs_head==NULL && eok->evs_tail==NULL && eok->evs_count==0, + "internal logic error: have you epoll_ctl(EPOLL_CTL_DEL) everything before calling epoll_close?"); A(eok->sv[0]==-1 && eok->sv[1]==-1, "internal logic error"); if (eok->kq!=-1) { close(eok->kq); @@ -825,6 +865,7 @@ static void eoks_free(ep_over_kq_t *eok) { } eok->next = eoks.eoks_free; eoks.eoks_free = eok; + *(eoks.eoks + eok->idx) = NULL; } while (0); A(0==pthread_mutex_unlock(&eoks.lock), ""); } @@ -837,7 +878,7 @@ static ep_over_kq_t* eoks_find(int epfd) { break; } A(eoks.eoks, "internal logic error"); - eok = eoks.eoks + epfd; + eok = *(eoks.eoks + epfd); A(eok->next==NULL, "internal logic error"); A(eok->lock_valid, "internal logic error"); } while (0); diff --git a/src/os/src/detail/CMakeLists.txt b/src/os/src/detail/CMakeLists.txt index e4052a4fb32d4d8bda1ea05443cf95c276251e57..1c5e55a522250a1532e35075616e9efddb008217 100644 --- a/src/os/src/detail/CMakeLists.txt +++ b/src/os/src/detail/CMakeLists.txt @@ -13,3 +13,4 @@ TARGET_LINK_LIBRARIES(osdetail os) IF (TD_ARM_32 OR TD_LINUX_32) TARGET_LINK_LIBRARIES(osdetail atomic) ENDIF () + diff --git a/src/plugins/http/CMakeLists.txt b/src/plugins/http/CMakeLists.txt index 56c3c25d7c8522d2d31522f4d1b6dce4df1af42b..274f50d24a42857c69c686bb22faede0577857d9 100644 --- a/src/plugins/http/CMakeLists.txt +++ b/src/plugins/http/CMakeLists.txt @@ -8,14 +8,29 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) INCLUDE_DIRECTORIES(inc) AUX_SOURCE_DIRECTORY(src SRC) - + IF (TD_LINUX) ADD_LIBRARY(http ${SRC}) TARGET_LINK_LIBRARIES(http z) IF (TD_SOMODE_STATIC) TARGET_LINK_LIBRARIES(http taos_static) - ELSE () + ELSE () + TARGET_LINK_LIBRARIES(http taos) + ENDIF () + + IF (TD_ADMIN) + TARGET_LINK_LIBRARIES(http admin) + ENDIF () +ENDIF () + +IF (TD_DARWIN) + ADD_LIBRARY(http ${SRC}) + TARGET_LINK_LIBRARIES(http z) + + IF (TD_SOMODE_STATIC) + TARGET_LINK_LIBRARIES(http taos_static) + ELSE () TARGET_LINK_LIBRARIES(http taos) ENDIF () diff --git a/src/plugins/http/src/httpServer.c b/src/plugins/http/src/httpServer.c index 1cc73aef06d1eeff877dbdd1871a51743dc81043..97a5b4bc235290bbe0c7c0d9bc6855fd18ad966f 100644 --- a/src/plugins/http/src/httpServer.c +++ b/src/plugins/http/src/httpServer.c @@ -31,11 +31,36 @@ static bool httpReadData(HttpContext *pContext); +#ifdef __APPLE__ +static int sv_dummy = 0; +#endif + static void httpStopThread(HttpThread* pThread) { pThread->stop = true; // signal the thread to stop, try graceful method first, // and use pthread_cancel when failed +#ifdef __APPLE__ + int sv[2]; + sv[0] = sv[1] = -1; + int r = socketpair(PF_LOCAL, SOCK_STREAM, 0, sv); + do { + if (r) break; + struct epoll_event ev = {0}; + ev.events = EPOLLIN; + ev.data.ptr = &sv_dummy; + 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)) { + r = -1; + break; + } + } while (0); + if (r) { + pthread_cancel(pThread->thread); + } +#else // __APPLE__ struct epoll_event event = { .events = EPOLLIN }; eventfd_t fd = eventfd(1, 0); if (fd == -1) { @@ -46,11 +71,23 @@ static void httpStopThread(HttpThread* pThread) { httpError("%s, failed to call epoll_ctl, will call pthread_cancel instead, which may result in data corruption: %s", pThread->label, strerror(errno)); pthread_cancel(pThread->thread); } +#endif // __APPLE__ pthread_join(pThread->thread, NULL); +#ifdef __APPLE__ + if (sv[0]!=-1) { + close(sv[0]); + sv[0] = -1; + } + if (sv[1]!=-1) { + close(sv[1]); + sv[1] = -1; + } +#else // __APPLE__ if (fd != -1) { close(fd); } +#endif // __APPLE__ #ifdef __APPLE__ epoll_close(pThread->pollFd); @@ -97,6 +134,15 @@ static void httpProcessHttpData(void *param) { if (fdNum <= 0) continue; for (int32_t i = 0; i < fdNum; ++i) { +#ifdef __APPLE__ + if (events[i].data.ptr == &sv_dummy) { + // no need to drain the recv buffer of sv[0] + // since there's only one time to send at most 1 byte to sv[0] + // btw, pThread->stop shall be already set, thus never reached here + httpDebug("if you see this line, there's internal logic error"); + continue; + } +#endif // __APPLE__ pContext = httpGetContext(events[i].data.ptr); if (pContext == NULL) { httpError("context:%p, is already released, close connect", events[i].data.ptr); diff --git a/src/plugins/monitor/CMakeLists.txt b/src/plugins/monitor/CMakeLists.txt index 90189c9d75b16a3689a8b6447d4ece4eb9766e1b..6b26c0447ab000023b7d79dc4c2c80cf81362630 100644 --- a/src/plugins/monitor/CMakeLists.txt +++ b/src/plugins/monitor/CMakeLists.txt @@ -8,10 +8,20 @@ AUX_SOURCE_DIRECTORY(./src SRC) IF (TD_LINUX) 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 () -ENDIF () +ENDIF () diff --git a/src/plugins/mqtt/CMakeLists.txt b/src/plugins/mqtt/CMakeLists.txt index 3761f70134501a5db7b7d5080e5a5bcf5f592858..b6de4215170be827c9e049044508d586ae6a6977 100644 --- a/src/plugins/mqtt/CMakeLists.txt +++ b/src/plugins/mqtt/CMakeLists.txt @@ -18,3 +18,15 @@ IF (TD_LINUX) TARGET_LINK_LIBRARIES(mqtt taos) ENDIF () ENDIF () + +IF (TD_DARWIN) + ADD_LIBRARY(mqtt ${SRC}) + TARGET_LINK_LIBRARIES(mqtt cJson mqttc) + + IF (TD_SOMODE_STATIC) + TARGET_LINK_LIBRARIES(mqtt taos_static) + ELSE () + TARGET_LINK_LIBRARIES(mqtt taos) + ENDIF () +ENDIF () + diff --git a/src/query/CMakeLists.txt b/src/query/CMakeLists.txt index e403251858bdea2c89cc050ab3dbe3a5110843e3..967e86de3c5d9288834e3eb3b3222e551009bc49 100644 --- a/src/query/CMakeLists.txt +++ b/src/query/CMakeLists.txt @@ -14,3 +14,8 @@ IF (TD_LINUX) TARGET_LINK_LIBRARIES(query m rt) ADD_SUBDIRECTORY(tests) ENDIF () + +IF (TD_DARWIN) + TARGET_LINK_LIBRARIES(query m) + ADD_SUBDIRECTORY(tests) +ENDIF () diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index 2bdc58390db6a80b1b2669ab21d999b2da94cefd..ba90f93073051c0c8c776496a3f3f77688764867 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -308,7 +308,10 @@ void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void * pthread_attr_destroy(&thattr); if (code != 0) { #ifdef __APPLE__ - epoll_close(pThreadObj->pollFd); + if (pThreadObj->pollFd!=-1) { + epoll_close(pThreadObj->pollFd); + pThreadObj->pollFd = -1; + } #else taosCloseSocket(pThreadObj->pollFd); #endif @@ -517,7 +520,10 @@ static void *taosProcessTcpData(void *param) { } #ifdef __APPLE__ - if (pThreadObj->pollFd >=0) epoll_close(pThreadObj->pollFd); + if (pThreadObj->pollFd >=0) { + epoll_close(pThreadObj->pollFd); + pThreadObj->pollFd = -1; + } #else if (pThreadObj->pollFd >=0) taosCloseSocket(pThreadObj->pollFd); #endif diff --git a/src/rpc/test/CMakeLists.txt b/src/rpc/test/CMakeLists.txt index 9a4bcc353d9bd1ad8ee8b6ef546f8e4a44f75559..e9231058600ce2135f669dd42a6c52cca81424cd 100644 --- a/src/rpc/test/CMakeLists.txt +++ b/src/rpc/test/CMakeLists.txt @@ -16,3 +16,17 @@ IF (TD_LINUX) ADD_EXECUTABLE(rserver ${SERVER_SRC}) TARGET_LINK_LIBRARIES(rserver trpc) ENDIF () + +IF (TD_DARWIN) + LIST(APPEND CLIENT_SRC ./rclient.c) + ADD_EXECUTABLE(rclient ${CLIENT_SRC}) + TARGET_LINK_LIBRARIES(rclient trpc) + + LIST(APPEND SCLIENT_SRC ./rsclient.c) + ADD_EXECUTABLE(rsclient ${SCLIENT_SRC}) + TARGET_LINK_LIBRARIES(rsclient trpc) + + LIST(APPEND SERVER_SRC ./rserver.c) + ADD_EXECUTABLE(rserver ${SERVER_SRC}) + TARGET_LINK_LIBRARIES(rserver trpc) +ENDIF () diff --git a/src/sync/CMakeLists.txt b/src/sync/CMakeLists.txt index 6a533808415929776be46a96266dd7cdaeca0bf3..3721163f798bd2f5349f58fd66a680ac24a4bf5d 100644 --- a/src/sync/CMakeLists.txt +++ b/src/sync/CMakeLists.txt @@ -3,7 +3,7 @@ PROJECT(TDengine) INCLUDE_DIRECTORIES(inc) AUX_SOURCE_DIRECTORY(src SRC) - + IF (TD_LINUX) LIST(REMOVE_ITEM SRC src/syncArbitrator.c) ADD_LIBRARY(sync ${SRC}) @@ -16,3 +16,16 @@ IF (TD_LINUX) #ADD_SUBDIRECTORY(test) ENDIF () + +IF (TD_DARWIN) + LIST(REMOVE_ITEM SRC src/syncArbitrator.c) + ADD_LIBRARY(sync ${SRC}) + TARGET_LINK_LIBRARIES(sync tutil pthread common) + + LIST(APPEND BIN_SRC src/syncArbitrator.c) + LIST(APPEND BIN_SRC src/syncTcp.c) + ADD_EXECUTABLE(tarbitrator ${BIN_SRC}) + TARGET_LINK_LIBRARIES(tarbitrator sync common osdetail tutil) + + #ADD_SUBDIRECTORY(test) +ENDIF () diff --git a/src/sync/src/syncRetrieve.c b/src/sync/src/syncRetrieve.c index cb2379583f853be70bc2e735c81f711a18dc9b52..7678a7d2842879079df62e8b5798a8cf7c0733a0 100644 --- a/src/sync/src/syncRetrieve.c +++ b/src/sync/src/syncRetrieve.c @@ -14,7 +14,7 @@ */ #define _DEFAULT_SOURCE -#include +// #include #include "os.h" #include "taoserror.h" #include "tlog.h" diff --git a/src/sync/test/CMakeLists.txt b/src/sync/test/CMakeLists.txt index 256e87580d9372f0ade7200591303211f0140952..ab2e6c307bd7f69f1faf2fc578b3dcf8d43c4c84 100644 --- a/src/sync/test/CMakeLists.txt +++ b/src/sync/test/CMakeLists.txt @@ -13,4 +13,3 @@ IF (TD_LINUX) TARGET_LINK_LIBRARIES(syncServer sync trpc common) ENDIF () - diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 48b4d7656105aed1a983fad59c20195f0d3fcb77..3606aea76b91c8bc272cf658065443f65fd3fd28 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -5,7 +5,7 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/rpc/inc) AUX_SOURCE_DIRECTORY(src SRC) ADD_LIBRARY(tutil ${SRC}) TARGET_LINK_LIBRARIES(tutil pthread osdetail lz4 z) - + IF (TD_LINUX) TARGET_LINK_LIBRARIES(tutil m rt) # ADD_SUBDIRECTORY(tests) @@ -28,5 +28,6 @@ IF (TD_LINUX) ELSEIF (TD_WINDOWS) TARGET_LINK_LIBRARIES(tutil iconv regex winmm IPHLPAPI ws2_32 wepoll) ELSEIF(TD_DARWIN) + TARGET_LINK_LIBRARIES(tutil m) TARGET_LINK_LIBRARIES(tutil iconv) ENDIF() diff --git a/src/vnode/CMakeLists.txt b/src/vnode/CMakeLists.txt index c953883361ac80d6a962b3b35045792eae48dfae..3a2617241128ffd318f2aab49e60e455bee00208 100644 --- a/src/vnode/CMakeLists.txt +++ b/src/vnode/CMakeLists.txt @@ -13,3 +13,9 @@ IF (TD_LINUX) 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 () + diff --git a/src/wal/CMakeLists.txt b/src/wal/CMakeLists.txt index 681bed54258353b7ceff6df3c84909cbcadaa6b8..d3cd86df50986cbb298bcae1a07db71a2c1a71dc 100644 --- a/src/wal/CMakeLists.txt +++ b/src/wal/CMakeLists.txt @@ -8,4 +8,10 @@ IF (TD_LINUX) ADD_LIBRARY(twal ${SRC}) TARGET_LINK_LIBRARIES(twal tutil common) ADD_SUBDIRECTORY(test) -ENDIF () +ENDIF () + +IF (TD_DARWIN) + ADD_LIBRARY(twal ${SRC}) + TARGET_LINK_LIBRARIES(twal tutil common) + ADD_SUBDIRECTORY(test) +ENDIF () diff --git a/src/wal/test/CMakeLists.txt b/src/wal/test/CMakeLists.txt index b8338b1738a840d43d6f073e5562f0e1ffacf851..aec0602ac00c6b943b4dd6c20c219d17223ee896 100644 --- a/src/wal/test/CMakeLists.txt +++ b/src/wal/test/CMakeLists.txt @@ -10,4 +10,12 @@ IF (TD_LINUX) ENDIF () +IF (TD_DARWIN) + INCLUDE_DIRECTORIES(../inc) + + LIST(APPEND WALTEST_SRC ./waltest.c) + ADD_EXECUTABLE(waltest ${WALTEST_SRC}) + TARGET_LINK_LIBRARIES(waltest twal osdetail tutil) + +ENDIF () diff --git a/tests/comparisonTest/tdengine/CMakeLists.txt b/tests/comparisonTest/tdengine/CMakeLists.txt index aaa18592ed29b6e39c97a55e68e4867684817bbf..a12e36ab6b9b40992c0231bd36567ab0df0d9d7c 100644 --- a/tests/comparisonTest/tdengine/CMakeLists.txt +++ b/tests/comparisonTest/tdengine/CMakeLists.txt @@ -5,3 +5,8 @@ IF (TD_LINUX) add_executable(tdengineTest tdengineTest.c) target_link_libraries(tdengineTest taos_static tutil common pthread) ENDIF() + +IF (TD_DARWIN) + add_executable(tdengineTest tdengineTest.c) + target_link_libraries(tdengineTest taos_static tutil common pthread) +ENDIF() diff --git a/tests/examples/c/CMakeLists.txt b/tests/examples/c/CMakeLists.txt index 7cacefda57160cd437c876fcaccde85e00876bd8..5af7935c6b680032b6e4c7cf88488509dd634caa 100644 --- a/tests/examples/c/CMakeLists.txt +++ b/tests/examples/c/CMakeLists.txt @@ -10,6 +10,9 @@ IF (TD_LINUX) ENDIF () IF (TD_DARWIN) INCLUDE_DIRECTORIES(. ${TD_COMMUNITY_DIR}/src/inc ${TD_COMMUNITY_DIR}/src/client/inc ${TD_COMMUNITY_DIR}/inc) + AUX_SOURCE_DIRECTORY(. SRC) + ADD_EXECUTABLE(demo demo.c) + TARGET_LINK_LIBRARIES(demo taos_static trpc tutil pthread ) ADD_EXECUTABLE(epoll epoll.c) TARGET_LINK_LIBRARIES(epoll taos_static trpc tutil pthread ) ENDIF () diff --git a/tests/examples/c/demo.c b/tests/examples/c/demo.c index 54e81d33b9c7a948dc75996828bc07634d4664ae..f5ad37acefb50893248d510b43cce902cbcf8bc8 100644 --- a/tests/examples/c/demo.c +++ b/tests/examples/c/demo.c @@ -86,7 +86,7 @@ void Test(TAOS *taos, char *qstr, int index) { int i = 0; for (i = 0; i < 10; ++i) { - sprintf(qstr, "insert into m1 values (%" PRId64 ", %d, %d, %d, %d, %f, %lf, '%s')", 1546300800000 + i * 1000, i, i, i, i*10000000, i*1.0, i*2.0, "hello"); + sprintf(qstr, "insert into m1 values (%" PRId64 ", %d, %d, %d, %d, %f, %lf, '%s')", 1546300800000LL + i * 1000, i, i, i, i*10000000, i*1.0, i*2.0, "hello"); printf("qstr: %s\n", qstr); // note: how do you wanna do if taos_query returns non-NULL