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

1. sem_xxx -> tsem_xxx

2. SystemUid
上级 17de4655
......@@ -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;
......
......@@ -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;
}
......@@ -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
......
......@@ -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) {
......
......@@ -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);
}
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册