提交 7960dbe1 编写于 作者: F freemine

1. sem_xxx -> tsem_xxx

2. SystemUid
上级 17de4655
...@@ -138,14 +138,6 @@ void mnodeDecClusterRef(SClusterObj *pCluster) { ...@@ -138,14 +138,6 @@ void mnodeDecClusterRef(SClusterObj *pCluster) {
sdbDecRef(tsClusterSdb, 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() { static int32_t mnodeCreateCluster() {
int64_t numOfClusters = sdbGetNumOfRows(tsClusterSdb); int64_t numOfClusters = sdbGetNumOfRows(tsClusterSdb);
if (numOfClusters != 0) return TSDB_CODE_SUCCESS; if (numOfClusters != 0) return TSDB_CODE_SUCCESS;
......
...@@ -103,4 +103,15 @@ int taosSystem(const char *cmd) { ...@@ -103,4 +103,15 @@ int taosSystem(const char *cmd) {
void taosSetCoreDump() {} void taosSetCoreDump() {}
char *taosGetCmdlineByPID(int pid) { return ""; } char *taosGetCmdlineByPID(int pid) {
\ No newline at end of file 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;
}
...@@ -233,11 +233,7 @@ typedef struct { ...@@ -233,11 +233,7 @@ typedef struct {
SMemTable* mem; SMemTable* mem;
SMemTable* imem; SMemTable* imem;
STsdbFileH* tsdbFileH; STsdbFileH* tsdbFileH;
#ifdef __APPLE__ tsem_t readyToCommit;
sem_t *readyToCommit;
#else // __APPLE__
sem_t readyToCommit;
#endif // __APPLE__
pthread_mutex_t mutex; pthread_mutex_t mutex;
bool repoLocked; bool repoLocked;
int32_t code; // Commit code int32_t code; // Commit code
......
...@@ -166,11 +166,7 @@ static void tsdbEndCommit(STsdbRepo *pRepo, int eno) { ...@@ -166,11 +166,7 @@ static void tsdbEndCommit(STsdbRepo *pRepo, int eno) {
pRepo->imem = NULL; pRepo->imem = NULL;
tsdbUnlockRepo(pRepo); tsdbUnlockRepo(pRepo);
tsdbUnRefMemTable(pRepo, pIMem); tsdbUnRefMemTable(pRepo, pIMem);
#ifdef __APPLE__ tsem_post(&(pRepo->readyToCommit));
sem_post(pRepo->readyToCommit);
#else // __APPLE__
sem_post(&(pRepo->readyToCommit));
#endif // __APPLE__
} }
static int tsdbHasDataToCommit(SCommitIter *iters, int nIters, TSKEY minKey, TSKEY maxKey) { static int tsdbHasDataToCommit(SCommitIter *iters, int nIters, TSKEY minKey, TSKEY maxKey) {
......
...@@ -146,11 +146,7 @@ int tsdbCloseRepo(TSDB_REPO_T *repo, int toCommit) { ...@@ -146,11 +146,7 @@ int tsdbCloseRepo(TSDB_REPO_T *repo, int toCommit) {
if (toCommit) { if (toCommit) {
tsdbAsyncCommit(pRepo); tsdbAsyncCommit(pRepo);
#ifdef __APPLE__ tsem_wait(&(pRepo->readyToCommit));
sem_wait(pRepo->readyToCommit);
#else // __APPLE__
sem_wait(&(pRepo->readyToCommit));
#endif // __APPLE__
terrno = pRepo->code; terrno = pRepo->code;
} }
tsdbUnRefMemTable(pRepo, pRepo->mem); tsdbUnRefMemTable(pRepo, pRepo->mem);
...@@ -647,21 +643,12 @@ static STsdbRepo *tsdbNewRepo(char *rootDir, STsdbAppH *pAppH, STsdbCfg *pCfg) { ...@@ -647,21 +643,12 @@ static STsdbRepo *tsdbNewRepo(char *rootDir, STsdbAppH *pAppH, STsdbCfg *pCfg) {
goto _err; goto _err;
} }
#ifdef __APPLE__ code = tsem_init(&(pRepo->readyToCommit), 0, 1);
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);
if (code != 0) { if (code != 0) {
code = errno; code = errno;
terrno = TAOS_SYSTEM_ERROR(code); terrno = TAOS_SYSTEM_ERROR(code);
goto _err; goto _err;
} }
#endif // __APPLE__
pRepo->repoLocked = false; pRepo->repoLocked = false;
...@@ -707,11 +694,7 @@ static void tsdbFreeRepo(STsdbRepo *pRepo) { ...@@ -707,11 +694,7 @@ static void tsdbFreeRepo(STsdbRepo *pRepo) {
// tsdbFreeMemTable(pRepo->mem); // tsdbFreeMemTable(pRepo->mem);
// tsdbFreeMemTable(pRepo->imem); // tsdbFreeMemTable(pRepo->imem);
tfree(pRepo->rootDir); tfree(pRepo->rootDir);
#ifdef __APPLE__ tsem_destroy(&(pRepo->readyToCommit));
sem_close(pRepo->readyToCommit);
#else // __APPLE__
sem_destroy(&(pRepo->readyToCommit));
#endif // __APPLE__
pthread_mutex_destroy(&pRepo->mutex); pthread_mutex_destroy(&pRepo->mutex);
free(pRepo); free(pRepo);
} }
......
...@@ -207,11 +207,7 @@ void *tsdbAllocBytes(STsdbRepo *pRepo, int bytes) { ...@@ -207,11 +207,7 @@ void *tsdbAllocBytes(STsdbRepo *pRepo, int bytes) {
int tsdbAsyncCommit(STsdbRepo *pRepo) { int tsdbAsyncCommit(STsdbRepo *pRepo) {
if (pRepo->mem == NULL) return 0; if (pRepo->mem == NULL) return 0;
#ifdef __APPLE__ tsem_wait(&(pRepo->readyToCommit));
sem_wait(pRepo->readyToCommit);
#else // __APPLE__
sem_wait(&(pRepo->readyToCommit));
#endif // __APPLE__
ASSERT(pRepo->imem == NULL); ASSERT(pRepo->imem == NULL);
...@@ -233,13 +229,8 @@ int tsdbSyncCommit(TSDB_REPO_T *repo) { ...@@ -233,13 +229,8 @@ int tsdbSyncCommit(TSDB_REPO_T *repo) {
STsdbRepo *pRepo = (STsdbRepo *)repo; STsdbRepo *pRepo = (STsdbRepo *)repo;
tsdbAsyncCommit(pRepo); tsdbAsyncCommit(pRepo);
#ifdef __APPLE__ tsem_wait(&(pRepo->readyToCommit));
sem_wait(pRepo->readyToCommit); tsem_post(&(pRepo->readyToCommit));
sem_post(pRepo->readyToCommit);
#else // __APPLE__
sem_wait(&(pRepo->readyToCommit));
sem_post(&(pRepo->readyToCommit));
#endif // __APPLE__
if (pRepo->code != TSDB_CODE_SUCCESS) { if (pRepo->code != TSDB_CODE_SUCCESS) {
terrno = pRepo->code; terrno = pRepo->code;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册