parent
6485afb69d
commit
94eb0e1e71
|
@ -2520,9 +2520,9 @@ bool tscSetSqlOwner(SSqlObj* pSql) {
|
||||||
// set the sql object owner
|
// set the sql object owner
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
pthread_t threadId = (pthread_t)taosGetSelfPthreadId();
|
pthread_t threadId = (pthread_t)taosGetSelfPthreadId();
|
||||||
#else
|
#else // __APPLE__
|
||||||
uint64_t threadId = taosGetSelfPthreadId();
|
uint64_t threadId = taosGetSelfPthreadId();
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
if (atomic_val_compare_exchange_64(&pSql->owner, 0, threadId) != 0) {
|
if (atomic_val_compare_exchange_64(&pSql->owner, 0, threadId) != 0) {
|
||||||
pRes->code = TSDB_CODE_QRY_IN_EXEC;
|
pRes->code = TSDB_CODE_QRY_IN_EXEC;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -164,7 +164,7 @@ static void signal_handler(int32_t signum, siginfo_t *sigInfo, void *context) {
|
||||||
dInfo("shut down signal is %d, sender PID:%d", signum, sigInfo->si_pid);
|
dInfo("shut down signal is %d, sender PID:%d", signum, sigInfo->si_pid);
|
||||||
#else // __APPLE__
|
#else // __APPLE__
|
||||||
dInfo("shut down signal is %d, sender PID:%d cmdline:%s", signum, sigInfo->si_pid, taosGetCmdlineByPID(sigInfo->si_pid));
|
dInfo("shut down signal is %d, sender PID:%d cmdline:%s", signum, sigInfo->si_pid, taosGetCmdlineByPID(sigInfo->si_pid));
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
|
|
||||||
// protect the application from receive another signal
|
// protect the application from receive another signal
|
||||||
struct sigaction act = {{0}};
|
struct sigaction act = {{0}};
|
||||||
|
|
|
@ -241,7 +241,7 @@ static int sem_timedwait(tsem_t *sem, struct timespec *to) {
|
||||||
fprintf(stderr, "%s[%d]%s(): not implemented yet!\n", basename(__FILE__), __LINE__, __func__);
|
fprintf(stderr, "%s[%d]%s(): not implemented yet!\n", basename(__FILE__), __LINE__, __func__);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
|
|
||||||
static void* telemetryThread(void* param) {
|
static void* telemetryThread(void* param) {
|
||||||
struct timespec end = {0};
|
struct timespec end = {0};
|
||||||
|
|
|
@ -145,6 +145,7 @@ bool taosGetSystemUid(char *uid) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
static int32_t mnodeCreateCluster() {
|
static int32_t mnodeCreateCluster() {
|
||||||
int32_t numOfClusters = sdbGetNumOfRows(tsClusterSdb);
|
int32_t numOfClusters = sdbGetNumOfRows(tsClusterSdb);
|
||||||
if (numOfClusters != 0) return TSDB_CODE_SUCCESS;
|
if (numOfClusters != 0) return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -75,11 +75,11 @@ extern "C" {
|
||||||
#define TAOS_OS_FUNC_FILE_SENDIFLE
|
#define TAOS_OS_FUNC_FILE_SENDIFLE
|
||||||
|
|
||||||
#define TAOS_OS_FUNC_SEMPHONE
|
#define TAOS_OS_FUNC_SEMPHONE
|
||||||
#define tsem_t dispatch_semaphore_t
|
typedef struct tsem_s *tsem_t;
|
||||||
int tsem_init(dispatch_semaphore_t *sem, int pshared, unsigned int value);
|
int tsem_init(tsem_t *sem, int pshared, unsigned int value);
|
||||||
int tsem_wait(dispatch_semaphore_t *sem);
|
int tsem_wait(tsem_t *sem);
|
||||||
int tsem_post(dispatch_semaphore_t *sem);
|
int tsem_post(tsem_t *sem);
|
||||||
int tsem_destroy(dispatch_semaphore_t *sem);
|
int tsem_destroy(tsem_t *sem);
|
||||||
|
|
||||||
#define TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
|
#define TAOS_OS_FUNC_SOCKET_SETSOCKETOPT
|
||||||
#define TAOS_OS_FUNC_STRING_STR2INT64
|
#define TAOS_OS_FUNC_STRING_STR2INT64
|
||||||
|
|
|
@ -90,11 +90,12 @@ extern "C" {
|
||||||
#ifdef _ISOC11_SOURCE
|
#ifdef _ISOC11_SOURCE
|
||||||
#define threadlocal _Thread_local
|
#define threadlocal _Thread_local
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#define threadlocal
|
#define threadlocal __thread
|
||||||
#elif defined(__GNUC__) && !defined(threadlocal)
|
#elif defined(__GNUC__) && !defined(threadlocal)
|
||||||
#define threadlocal __thread
|
#define threadlocal __thread
|
||||||
#else
|
#else
|
||||||
#define threadlocal
|
// #define threadlocal
|
||||||
|
#error please follow with the target platform's thread-local implementation
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -33,7 +33,7 @@ static bool httpReadData(HttpContext *pContext);
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
static int sv_dummy = 0;
|
static int sv_dummy = 0;
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
|
|
||||||
static void httpStopThread(HttpThread* pThread) {
|
static void httpStopThread(HttpThread* pThread) {
|
||||||
pThread->stop = true;
|
pThread->stop = true;
|
||||||
|
|
|
@ -312,9 +312,9 @@ void *taosInitTcpClient(uint32_t ip, uint16_t port, char *label, int num, void *
|
||||||
epoll_close(pThreadObj->pollFd);
|
epoll_close(pThreadObj->pollFd);
|
||||||
pThreadObj->pollFd = -1;
|
pThreadObj->pollFd = -1;
|
||||||
}
|
}
|
||||||
#else
|
#else // __APPLE__
|
||||||
taosCloseSocket(pThreadObj->pollFd);
|
taosCloseSocket(pThreadObj->pollFd);
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
free(pThreadObj);
|
free(pThreadObj);
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
tError("%s failed to create TCP read data thread(%s)", label, strerror(errno));
|
tError("%s failed to create TCP read data thread(%s)", label, strerror(errno));
|
||||||
|
@ -478,6 +478,9 @@ static void *taosProcessTcpData(void *param) {
|
||||||
struct epoll_event events[maxEvents];
|
struct epoll_event events[maxEvents];
|
||||||
SRecvInfo recvInfo;
|
SRecvInfo recvInfo;
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
taos_block_sigalrm();
|
||||||
|
#endif // __APPLE__
|
||||||
while (1) {
|
while (1) {
|
||||||
int fdNum = epoll_wait(pThreadObj->pollFd, events, maxEvents, TAOS_EPOLL_WAIT_TIME);
|
int fdNum = epoll_wait(pThreadObj->pollFd, events, maxEvents, TAOS_EPOLL_WAIT_TIME);
|
||||||
if (pThreadObj->stop) {
|
if (pThreadObj->stop) {
|
||||||
|
@ -524,9 +527,9 @@ static void *taosProcessTcpData(void *param) {
|
||||||
epoll_close(pThreadObj->pollFd);
|
epoll_close(pThreadObj->pollFd);
|
||||||
pThreadObj->pollFd = -1;
|
pThreadObj->pollFd = -1;
|
||||||
}
|
}
|
||||||
#else
|
#else // __APPLE__
|
||||||
if (pThreadObj->pollFd >=0) taosCloseSocket(pThreadObj->pollFd);
|
if (pThreadObj->pollFd >=0) taosCloseSocket(pThreadObj->pollFd);
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
|
|
||||||
while (pThreadObj->pHead) {
|
while (pThreadObj->pHead) {
|
||||||
SFdObj *pFdObj = pThreadObj->pHead;
|
SFdObj *pFdObj = pThreadObj->pHead;
|
||||||
|
|
|
@ -235,9 +235,9 @@ static void *syncProcessTcpData(void *param) {
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
epoll_close(pThread->pollFd);
|
epoll_close(pThread->pollFd);
|
||||||
#else
|
#else // __APPLE__
|
||||||
close(pThread->pollFd);
|
close(pThread->pollFd);
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
tfree(pThread);
|
tfree(pThread);
|
||||||
tfree(buffer);
|
tfree(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -296,9 +296,9 @@ static SThreadObj *syncGetTcpThread(SPoolObj *pPool) {
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
epoll_close(pThread->pollFd);
|
epoll_close(pThread->pollFd);
|
||||||
#else
|
#else // __APPLE__
|
||||||
close(pThread->pollFd);
|
close(pThread->pollFd);
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
tfree(pThread);
|
tfree(pThread);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,9 +235,9 @@ typedef struct {
|
||||||
STsdbFileH* tsdbFileH;
|
STsdbFileH* tsdbFileH;
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
sem_t *readyToCommit;
|
sem_t *readyToCommit;
|
||||||
#else
|
#else // __APPLE__
|
||||||
sem_t readyToCommit;
|
sem_t readyToCommit;
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
bool repoLocked;
|
bool repoLocked;
|
||||||
int32_t code; // Commit code
|
int32_t code; // Commit code
|
||||||
|
|
|
@ -168,9 +168,9 @@ static void tsdbEndCommit(STsdbRepo *pRepo, int eno) {
|
||||||
tsdbUnRefMemTable(pRepo, pIMem);
|
tsdbUnRefMemTable(pRepo, pIMem);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
sem_post(pRepo->readyToCommit);
|
sem_post(pRepo->readyToCommit);
|
||||||
#else
|
#else // __APPLE__
|
||||||
sem_post(&(pRepo->readyToCommit));
|
sem_post(&(pRepo->readyToCommit));
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tsdbHasDataToCommit(SCommitIter *iters, int nIters, TSKEY minKey, TSKEY maxKey) {
|
static int tsdbHasDataToCommit(SCommitIter *iters, int nIters, TSKEY minKey, TSKEY maxKey) {
|
||||||
|
|
|
@ -148,9 +148,9 @@ int tsdbCloseRepo(TSDB_REPO_T *repo, int toCommit) {
|
||||||
tsdbAsyncCommit(pRepo);
|
tsdbAsyncCommit(pRepo);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
sem_wait(pRepo->readyToCommit);
|
sem_wait(pRepo->readyToCommit);
|
||||||
#else
|
#else // __APPLE__
|
||||||
sem_wait(&(pRepo->readyToCommit));
|
sem_wait(&(pRepo->readyToCommit));
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
terrno = pRepo->code;
|
terrno = pRepo->code;
|
||||||
}
|
}
|
||||||
tsdbUnRefMemTable(pRepo, pRepo->mem);
|
tsdbUnRefMemTable(pRepo, pRepo->mem);
|
||||||
|
@ -654,14 +654,14 @@ static STsdbRepo *tsdbNewRepo(char *rootDir, STsdbAppH *pAppH, STsdbCfg *pCfg) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(code);
|
terrno = TAOS_SYSTEM_ERROR(code);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
#else
|
#else // __APPLE__
|
||||||
code = sem_init(&(pRepo->readyToCommit), 0, 1);
|
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
|
#endif // __APPLE__
|
||||||
|
|
||||||
pRepo->repoLocked = false;
|
pRepo->repoLocked = false;
|
||||||
|
|
||||||
|
@ -709,9 +709,9 @@ static void tsdbFreeRepo(STsdbRepo *pRepo) {
|
||||||
tfree(pRepo->rootDir);
|
tfree(pRepo->rootDir);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
sem_close(pRepo->readyToCommit);
|
sem_close(pRepo->readyToCommit);
|
||||||
#else
|
#else // __APPLE__
|
||||||
sem_destroy(&(pRepo->readyToCommit));
|
sem_destroy(&(pRepo->readyToCommit));
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
pthread_mutex_destroy(&pRepo->mutex);
|
pthread_mutex_destroy(&pRepo->mutex);
|
||||||
free(pRepo);
|
free(pRepo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,9 +209,9 @@ int tsdbAsyncCommit(STsdbRepo *pRepo) {
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
sem_wait(pRepo->readyToCommit);
|
sem_wait(pRepo->readyToCommit);
|
||||||
#else
|
#else // __APPLE__
|
||||||
sem_wait(&(pRepo->readyToCommit));
|
sem_wait(&(pRepo->readyToCommit));
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
|
|
||||||
ASSERT(pRepo->imem == NULL);
|
ASSERT(pRepo->imem == NULL);
|
||||||
|
|
||||||
|
@ -236,10 +236,10 @@ int tsdbSyncCommit(TSDB_REPO_T *repo) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
sem_wait(pRepo->readyToCommit);
|
sem_wait(pRepo->readyToCommit);
|
||||||
sem_post(pRepo->readyToCommit);
|
sem_post(pRepo->readyToCommit);
|
||||||
#else
|
#else // __APPLE__
|
||||||
sem_wait(&(pRepo->readyToCommit));
|
sem_wait(&(pRepo->readyToCommit));
|
||||||
sem_post(&(pRepo->readyToCommit));
|
sem_post(&(pRepo->readyToCommit));
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
|
|
||||||
if (pRepo->code != TSDB_CODE_SUCCESS) {
|
if (pRepo->code != TSDB_CODE_SUCCESS) {
|
||||||
terrno = pRepo->code;
|
terrno = pRepo->code;
|
||||||
|
|
|
@ -376,7 +376,7 @@ int32_t taosKeepTcpAlive(SOCKET sockFd) {
|
||||||
taosCloseSocket(sockFd);
|
taosCloseSocket(sockFd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
|
|
||||||
int32_t nodelay = 1;
|
int32_t nodelay = 1;
|
||||||
if (taosSetSockOpt(sockFd, IPPROTO_TCP, TCP_NODELAY, (void *)&nodelay, sizeof(nodelay)) < 0) {
|
if (taosSetSockOpt(sockFd, IPPROTO_TCP, TCP_NODELAY, (void *)&nodelay, sizeof(nodelay)) < 0) {
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include "eok.h"
|
#include "eok.h"
|
||||||
#else
|
#else // __APPLE__
|
||||||
#include <sys/epoll.h>
|
#include <sys/epoll.h>
|
||||||
#endif
|
#endif // __APPLE__
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
Loading…
Reference in New Issue