diff --git a/src/mnode/src/mnodeCluster.c b/src/mnode/src/mnodeCluster.c index 94ec59b1b085208349d17dfa6ed203b36ebbf61b..169d2ebd9dae1bcc34ea24dd3770951f9cbb442b 100644 --- a/src/mnode/src/mnodeCluster.c +++ b/src/mnode/src/mnodeCluster.c @@ -138,14 +138,6 @@ 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() { int64_t numOfClusters = sdbGetNumOfRows(tsClusterSdb); if (numOfClusters != 0) return TSDB_CODE_SUCCESS; diff --git a/src/os/src/darwin/darwinSysInfo.c b/src/os/src/darwin/darwinSysInfo.c index ad3facdcee50775aeea0794b60c0d9f82d1de538..cf799d7f55a0b6c084bb563e4cb00ec256bbc8e3 100644 --- a/src/os/src/darwin/darwinSysInfo.c +++ b/src/os/src/darwin/darwinSysInfo.c @@ -103,4 +103,15 @@ int taosSystem(const char *cmd) { void taosSetCoreDump() {} -char *taosGetCmdlineByPID(int pid) { return ""; } \ No newline at end of file +char *taosGetCmdlineByPID(int pid) { + return "[not supported yet]"; +} + +bool taosGetSystemUid(char *uid) { + uuid_t uuid = {0}; + uuid_generate(uuid); + // it's caller's responsibility to make enough space for `uid`, that's 36-char + 1-null + uuid_unparse(uuid, uid); + return true; +} + diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h index f3e69d92103b691b934bf0dee8ccbde324da89fa..05335b45d5850033918c1af503f3d505af2813c0 100644 --- a/src/tsdb/inc/tsdbMain.h +++ b/src/tsdb/inc/tsdbMain.h @@ -233,11 +233,7 @@ typedef struct { SMemTable* mem; SMemTable* imem; STsdbFileH* tsdbFileH; -#ifdef __APPLE__ - sem_t *readyToCommit; -#else // __APPLE__ - sem_t readyToCommit; -#endif // __APPLE__ + tsem_t readyToCommit; pthread_mutex_t mutex; bool repoLocked; int32_t code; // Commit code diff --git a/src/tsdb/src/tsdbCommit.c b/src/tsdb/src/tsdbCommit.c index b3f7f51327915831830a3e3e14940eab7c9b6478..cd8358e5e39c0b876841423d7881c3ee5ca7913b 100644 --- a/src/tsdb/src/tsdbCommit.c +++ b/src/tsdb/src/tsdbCommit.c @@ -166,11 +166,7 @@ static void tsdbEndCommit(STsdbRepo *pRepo, int eno) { pRepo->imem = NULL; tsdbUnlockRepo(pRepo); tsdbUnRefMemTable(pRepo, pIMem); -#ifdef __APPLE__ - sem_post(pRepo->readyToCommit); -#else // __APPLE__ - sem_post(&(pRepo->readyToCommit)); -#endif // __APPLE__ + tsem_post(&(pRepo->readyToCommit)); } static int tsdbHasDataToCommit(SCommitIter *iters, int nIters, TSKEY minKey, TSKEY maxKey) { diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index adab932bb607e7b8eaa79c816dcab6e89e9d9392..cadbfa91cf51abac00bcb0d77605ac96346ec46c 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -146,11 +146,7 @@ int tsdbCloseRepo(TSDB_REPO_T *repo, int toCommit) { if (toCommit) { tsdbAsyncCommit(pRepo); -#ifdef __APPLE__ - sem_wait(pRepo->readyToCommit); -#else // __APPLE__ - sem_wait(&(pRepo->readyToCommit)); -#endif // __APPLE__ + tsem_wait(&(pRepo->readyToCommit)); terrno = pRepo->code; } tsdbUnRefMemTable(pRepo, pRepo->mem); @@ -647,21 +643,12 @@ static STsdbRepo *tsdbNewRepo(char *rootDir, STsdbAppH *pAppH, STsdbCfg *pCfg) { goto _err; } -#ifdef __APPLE__ - pRepo->readyToCommit = sem_open(NULL, O_CREAT, 0644, 1); - if (pRepo->readyToCommit==SEM_FAILED) { - code = errno; - terrno = TAOS_SYSTEM_ERROR(code); - goto _err; - } -#else // __APPLE__ - code = sem_init(&(pRepo->readyToCommit), 0, 1); + code = tsem_init(&(pRepo->readyToCommit), 0, 1); if (code != 0) { code = errno; terrno = TAOS_SYSTEM_ERROR(code); goto _err; } -#endif // __APPLE__ pRepo->repoLocked = false; @@ -707,11 +694,7 @@ static void tsdbFreeRepo(STsdbRepo *pRepo) { // tsdbFreeMemTable(pRepo->mem); // tsdbFreeMemTable(pRepo->imem); tfree(pRepo->rootDir); -#ifdef __APPLE__ - sem_close(pRepo->readyToCommit); -#else // __APPLE__ - sem_destroy(&(pRepo->readyToCommit)); -#endif // __APPLE__ + tsem_destroy(&(pRepo->readyToCommit)); pthread_mutex_destroy(&pRepo->mutex); free(pRepo); } diff --git a/src/tsdb/src/tsdbMemTable.c b/src/tsdb/src/tsdbMemTable.c index 206a3332d57e4db3f4ce6fae4421298fd0736865..42bbebe5f7ae319e45cfd37bea6c1dd673be7904 100644 --- a/src/tsdb/src/tsdbMemTable.c +++ b/src/tsdb/src/tsdbMemTable.c @@ -207,11 +207,7 @@ void *tsdbAllocBytes(STsdbRepo *pRepo, int bytes) { int tsdbAsyncCommit(STsdbRepo *pRepo) { if (pRepo->mem == NULL) return 0; -#ifdef __APPLE__ - sem_wait(pRepo->readyToCommit); -#else // __APPLE__ - sem_wait(&(pRepo->readyToCommit)); -#endif // __APPLE__ + tsem_wait(&(pRepo->readyToCommit)); ASSERT(pRepo->imem == NULL); @@ -233,13 +229,8 @@ int tsdbSyncCommit(TSDB_REPO_T *repo) { STsdbRepo *pRepo = (STsdbRepo *)repo; tsdbAsyncCommit(pRepo); -#ifdef __APPLE__ - sem_wait(pRepo->readyToCommit); - sem_post(pRepo->readyToCommit); -#else // __APPLE__ - sem_wait(&(pRepo->readyToCommit)); - sem_post(&(pRepo->readyToCommit)); -#endif // __APPLE__ + tsem_wait(&(pRepo->readyToCommit)); + tsem_post(&(pRepo->readyToCommit)); if (pRepo->code != TSDB_CODE_SUCCESS) { terrno = pRepo->code;