From f441be13e45bd0733c1e35dfb681ffed21bf8ddd Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 1 Feb 2021 15:39:45 +0800 Subject: [PATCH] TD-1207 --- src/os/inc/osDarwin.h | 2 ++ src/os/inc/osSemphone.h | 8 ++++++++ src/os/src/windows/wWordexp.c | 2 +- src/tsdb/src/tsdbCommit.c | 4 +++- src/util/src/ttimer.c | 7 ++++++- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/os/inc/osDarwin.h b/src/os/inc/osDarwin.h index 14b8ccf53c..2a05d5682e 100644 --- a/src/os/inc/osDarwin.h +++ b/src/os/inc/osDarwin.h @@ -105,6 +105,8 @@ typedef int(*__compar_fn_t)(const void *, const void *); #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE #endif +#define TAOS_OS_FUNC_PTHREAD_RWLOCK + int64_t tsosStr2int64(char *str); #include "eok.h" diff --git a/src/os/inc/osSemphone.h b/src/os/inc/osSemphone.h index 74e1bd4878..7c64aa80e5 100644 --- a/src/os/inc/osSemphone.h +++ b/src/os/inc/osSemphone.h @@ -28,6 +28,14 @@ extern "C" { #define tsem_destroy sem_destroy #endif +#ifdef TAOS_OS_FUNC_PTHREAD_RWLOCK + #define pthread_rwlock_t pthread_mutex_t + #define pthread_rwlock_init(lock) pthread_mutex_init(lock) + #define pthread_mutex_destroy(lock) pthread_mutex_destroy(lock) + #define pthread_rwlock_wrlock(lock) pthread_mutex_lock(lock) + #define pthread_rwlock_unlock(lock) pthread_mutex_unlock(lock) +#endif + // TAOS_OS_FUNC_SEMPHONE_PTHREAD bool taosCheckPthreadValid(pthread_t thread); int64_t taosGetSelfPthreadId(); diff --git a/src/os/src/windows/wWordexp.c b/src/os/src/windows/wWordexp.c index fca283cb33..929505516d 100644 --- a/src/os/src/windows/wWordexp.c +++ b/src/os/src/windows/wWordexp.c @@ -27,7 +27,7 @@ int wordexp(char *words, wordexp_t *pwordexp, int flags) { pwordexp->we_wordv[0] = pwordexp->wordPos; memset(pwordexp->wordPos, 0, 1025); - if (_fullpath(words, pwordexp->wordPos, 1024) == NULL) { + if (_fullpath(pwordexp->wordPos, words, 1024) == NULL) { pwordexp->we_wordv[0] = words; uError("failed to parse relative path:%s to abs path", words); return -1; diff --git a/src/tsdb/src/tsdbCommit.c b/src/tsdb/src/tsdbCommit.c index ec9ea4fa15..3216b18459 100644 --- a/src/tsdb/src/tsdbCommit.c +++ b/src/tsdb/src/tsdbCommit.c @@ -280,10 +280,12 @@ static int tsdbDropMetaRecord(STsdbFS *pfs, SMFile *pMFile, uint64_t uid) { // =================== Commit Time-Series Data static int tsdbCommitTSData(STsdbRepo *pRepo) { SMemTable *pMem = pRepo->imem; - SCommitH commith = {0}; + SCommitH commith; SDFileSet *pSet = NULL; int fid; + memset(&commith, 0, sizeof(SMemTable *)); + if (pMem->numOfRows <= 0) { // No memory data, just apply retention on each file on disk if (tsdbApplyRtn(pRepo) < 0) { diff --git a/src/util/src/ttimer.c b/src/util/src/ttimer.c index 6029edf512..809b69e8ad 100644 --- a/src/util/src/ttimer.c +++ b/src/util/src/ttimer.c @@ -188,7 +188,11 @@ static void removeTimer(uintptr_t id) { } static int64_t getMonotonicMs(void) { +#ifdef WINDOWS return (int64_t) getMonotonicUs() / 1000; +#else + return taosGetTimestampMs(); +#endif } static void addToWheel(tmr_obj_t* timer, uint32_t delay) { @@ -537,7 +541,8 @@ static void taosTmrModuleInit(void) { } void* taosTmrInit(int maxNumOfTmrs, int resolution, int longest, const char* label) { - tmrInfo("ttimer monotonic clock source:%s", monotonicInit()); + const char* ret = monotonicInit(); + tmrInfo("ttimer monotonic clock source:%s", ret); pthread_once(&tmrModuleInit, taosTmrModuleInit); -- GitLab