Merge branch '3.0' into feature/TD-18581-D
This commit is contained in:
commit
9a8d8db37b
|
@ -27,9 +27,9 @@ extern "C" {
|
|||
|
||||
#define LIST_LENGTH(l) (NULL != (l) ? (l)->length : 0)
|
||||
|
||||
#define FOREACH(node, list) \
|
||||
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); \
|
||||
(NULL != cell ? (node = cell->pNode, true) : (node = NULL, false)); cell = cell->pNext)
|
||||
#define FOREACH(node, list) \
|
||||
for (SListCell *cell = (NULL != (list) ? (list)->pHead : NULL), *pNext; \
|
||||
(NULL != cell ? (node = cell->pNode, pNext = cell->pNext, true) : (node = NULL, pNext = NULL, false)); cell = pNext)
|
||||
|
||||
#define REPLACE_NODE(newNode) cell->pNode = (SNode*)(newNode)
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ uint32_t ip2uint(const char *const ip_addr);
|
|||
void taosIgnSIGPIPE();
|
||||
void taosSetMaskSIGPIPE();
|
||||
uint32_t taosInetAddr(const char *ipAddr);
|
||||
const char *taosInetNtoa(struct in_addr ipInt);
|
||||
const char *taosInetNtoa(struct in_addr ipInt, char *dstStr, int32_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -77,7 +77,6 @@ int32_t taosWcharsWidth(TdWchar *pWchar, int32_t size);
|
|||
int32_t taosMbToWchar(TdWchar *pWchar, const char *pStr, int32_t size);
|
||||
int32_t taosMbsToWchars(TdWchar *pWchars, const char *pStrs, int32_t size);
|
||||
int32_t taosWcharToMb(char *pStr, TdWchar wchar);
|
||||
int32_t taosWcharsToMbs(char *pStrs, TdWchar *pWchars, int32_t size);
|
||||
|
||||
char *taosStrCaseStr(const char *str, const char *pattern);
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
#define NCHAR_ADD_LEN 3 // L"nchar" 3 means L" "
|
||||
|
||||
#define MAX_RETRY_TIMES 5
|
||||
#define LINE_BATCH 20000
|
||||
#define LINE_BATCH 2000
|
||||
//=================================================================================================
|
||||
typedef TSDB_SML_PROTOCOL_TYPE SMLProtocolType;
|
||||
|
||||
|
@ -1532,6 +1532,7 @@ static SSmlHandle* smlBuildSmlInfo(STscObj* pTscObj, SRequestObj* request, SMLPr
|
|||
info->pRequest = request;
|
||||
info->msgBuf.buf = info->pRequest->msgBuf;
|
||||
info->msgBuf.len = ERROR_MSG_BUF_DEFAULT_SIZE;
|
||||
info->pRequest->stmtType = info->pQuery->pRoot->type;
|
||||
}
|
||||
|
||||
info->exec = smlInitHandle(info->pQuery);
|
||||
|
@ -2332,6 +2333,9 @@ static int32_t smlInsertData(SSmlHandle *info) {
|
|||
// info->affectedRows = taos_affected_rows(info->pRequest);
|
||||
// return info->pRequest->code;
|
||||
|
||||
SAppClusterSummary *pActivity = &info->taos->pAppInfo->summary;
|
||||
atomic_add_fetch_64((int64_t *)&pActivity->numOfInsertsReq, 1);
|
||||
|
||||
launchAsyncQuery(info->pRequest, info->pQuery, NULL);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -685,7 +685,9 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32;
|
||||
tsPrintAuth = cfgGetItem(pCfg, "printAuth")->bval;
|
||||
|
||||
#if !defined(WINDOWS) && !defined(DARWIN)
|
||||
tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval;
|
||||
#endif
|
||||
tsMnodeShmSize = cfgGetItem(pCfg, "mnodeShmSize")->i32;
|
||||
tsVnodeShmSize = cfgGetItem(pCfg, "vnodeShmSize")->i32;
|
||||
tsQnodeShmSize = cfgGetItem(pCfg, "qnodeShmSize")->i32;
|
||||
|
@ -919,7 +921,9 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
|||
}
|
||||
case 'u': {
|
||||
if (strcasecmp("multiProcess", name) == 0) {
|
||||
#if !defined(WINDOWS) && !defined(DARWIN)
|
||||
tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval;
|
||||
#endif
|
||||
} else if (strcasecmp("udfDebugFlag", name) == 0) {
|
||||
udfDebugFlag = cfgGetItem(pCfg, "udfDebugFlag")->i32;
|
||||
}
|
||||
|
|
|
@ -1604,7 +1604,7 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)dbname, false);
|
||||
|
||||
char stbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
char stbname[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(stbname, mndGetDbStr(pTrans->stbname), pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)stbname, false);
|
||||
|
|
|
@ -57,7 +57,7 @@ void syncUtilU642Addr(uint64_t u64, char* host, size_t len, uint16_t* port) {
|
|||
|
||||
struct in_addr addr;
|
||||
addr.s_addr = hostU32;
|
||||
snprintf(host, len, "%s", taosInetNtoa(addr));
|
||||
taosInetNtoa(addr, host, len);
|
||||
*port = (uint16_t)((u64 & 0x00000000FFFF0000) >> 16);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,24 @@ int wordexp(char *words, wordexp_t *pwordexp, int flags) {
|
|||
|
||||
void wordfree(wordexp_t *pwordexp) {}
|
||||
|
||||
#elif defined(DARWIN)
|
||||
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <wordexp.h>
|
||||
|
||||
typedef struct dirent dirent;
|
||||
typedef struct dirent TdDirEntry;
|
||||
|
||||
typedef struct TdDir {
|
||||
TdDirEntry dirEntry;
|
||||
TdDirEntry dirEntry1;
|
||||
TdDirEntryPtr dirEntryPtr;
|
||||
DIR *pDir;
|
||||
} TdDir;
|
||||
|
||||
#else
|
||||
|
||||
#include <dirent.h>
|
||||
|
@ -343,7 +361,7 @@ char *taosDirName(char *name) {
|
|||
name[0] = 0;
|
||||
}
|
||||
return name;
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
#else
|
||||
char *end = strrchr(name, '/');
|
||||
if (end != NULL) {
|
||||
*end = '\0';
|
||||
|
@ -351,8 +369,6 @@ char *taosDirName(char *name) {
|
|||
name[0] = 0;
|
||||
}
|
||||
return name;
|
||||
#else
|
||||
return dirname(name);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -362,7 +378,9 @@ char *taosDirEntryBaseName(char *name) {
|
|||
_splitpath(name, NULL, NULL, Filename1, Ext1);
|
||||
return name + (strlen(name) - strlen(Filename1) - strlen(Ext1));
|
||||
#else
|
||||
return (char *)basename(name);
|
||||
char *pPoint = strchr(name, '.');
|
||||
if (pPoint != NULL) pPoint = 0;
|
||||
return name;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -386,6 +404,13 @@ TdDirPtr taosOpenDir(const char *dirname) {
|
|||
return NULL;
|
||||
}
|
||||
return pDir;
|
||||
#elif defined(DARWIN)
|
||||
DIR *pDir = opendir(dirname);
|
||||
if (pDir == NULL) return NULL;
|
||||
TdDirPtr dirPtr = (TdDirPtr)taosMemoryMalloc(sizeof(TdDir));
|
||||
dirPtr->dirEntryPtr = (TdDirEntryPtr)&(dirPtr->dirEntry1);
|
||||
dirPtr->pDir = pDir;
|
||||
return dirPtr;
|
||||
#else
|
||||
return (TdDirPtr)opendir(dirname);
|
||||
#endif
|
||||
|
@ -400,6 +425,12 @@ TdDirEntryPtr taosReadDir(TdDirPtr pDir) {
|
|||
return NULL;
|
||||
}
|
||||
return (TdDirEntryPtr) & (pDir->dirEntry.findFileData);
|
||||
#elif defined(DARWIN)
|
||||
if (readdir_r(pDir->pDir, (dirent*)&(pDir->dirEntry), (dirent**)&(pDir->dirEntryPtr)) == 0) {
|
||||
return pDir->dirEntryPtr;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
return (TdDirEntryPtr)readdir((DIR *)pDir);
|
||||
#endif
|
||||
|
@ -436,6 +467,11 @@ int32_t taosCloseDir(TdDirPtr *ppDir) {
|
|||
taosMemoryFree(*ppDir);
|
||||
*ppDir = NULL;
|
||||
return 0;
|
||||
#elif defined(DARWIN)
|
||||
closedir((*ppDir)->pDir);
|
||||
taosMemoryFree(*ppDir);
|
||||
*ppDir = NULL;
|
||||
return 0;
|
||||
#else
|
||||
closedir((DIR *)*ppDir);
|
||||
*ppDir = NULL;
|
||||
|
|
|
@ -106,293 +106,8 @@ int32_t tsem_timewait(tsem_t* sem, int64_t nanosecs) {
|
|||
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
|
||||
/*
|
||||
* darwin implementation
|
||||
*/
|
||||
|
||||
#include <libproc.h>
|
||||
|
||||
// #define SEM_USE_PTHREAD
|
||||
// #define SEM_USE_POSIX
|
||||
// #define SEM_USE_SEM
|
||||
|
||||
// #ifdef SEM_USE_SEM
|
||||
// #include <mach/mach_error.h>
|
||||
// #include <mach/mach_init.h>
|
||||
// #include <mach/semaphore.h>
|
||||
// #include <mach/task.h>
|
||||
|
||||
// static TdThread sem_thread;
|
||||
// static TdThreadOnce sem_once;
|
||||
// static task_t sem_port;
|
||||
// static volatile int sem_inited = 0;
|
||||
// static semaphore_t sem_exit;
|
||||
|
||||
// static void *sem_thread_routine(void *arg) {
|
||||
// (void)arg;
|
||||
// setThreadName("sem_thrd");
|
||||
|
||||
// sem_port = mach_task_self();
|
||||
// kern_return_t ret = semaphore_create(sem_port, &sem_exit, SYNC_POLICY_FIFO, 0);
|
||||
// if (ret != KERN_SUCCESS) {
|
||||
// fprintf(stderr, "==%s[%d]%s()==failed to create sem_exit\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__);
|
||||
// sem_inited = -1;
|
||||
// return NULL;
|
||||
// }
|
||||
// sem_inited = 1;
|
||||
// semaphore_wait(sem_exit);
|
||||
// return NULL;
|
||||
// }
|
||||
|
||||
// static void once_init(void) {
|
||||
// int r = 0;
|
||||
// r = taosThreadCreate(&sem_thread, NULL, sem_thread_routine, NULL);
|
||||
// if (r) {
|
||||
// fprintf(stderr, "==%s[%d]%s()==failed to create thread\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__);
|
||||
// return;
|
||||
// }
|
||||
// while (sem_inited == 0) {
|
||||
// ;
|
||||
// }
|
||||
// }
|
||||
// #endif
|
||||
|
||||
// struct tsem_s {
|
||||
// #ifdef SEM_USE_PTHREAD
|
||||
// TdThreadMutex lock;
|
||||
// TdThreadCond cond;
|
||||
// volatile int64_t val;
|
||||
// #elif defined(SEM_USE_POSIX)
|
||||
// size_t id;
|
||||
// sem_t *sem;
|
||||
// #elif defined(SEM_USE_SEM)
|
||||
// semaphore_t sem;
|
||||
// #else // SEM_USE_PTHREAD
|
||||
// dispatch_semaphore_t sem;
|
||||
// #endif // SEM_USE_PTHREAD
|
||||
|
||||
// volatile unsigned int valid : 1;
|
||||
// };
|
||||
|
||||
// int tsem_init(tsem_t *sem, int pshared, unsigned int value) {
|
||||
// // fprintf(stderr, "==%s[%d]%s():[%p]==creating\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, sem);
|
||||
// if (*sem) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==already initialized\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__,
|
||||
// sem);
|
||||
// abort();
|
||||
// }
|
||||
// struct tsem_s *p = (struct tsem_s *)taosMemoryCalloc(1, sizeof(*p));
|
||||
// if (!p) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==out of memory\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, sem);
|
||||
// abort();
|
||||
// }
|
||||
|
||||
// #ifdef SEM_USE_PTHREAD
|
||||
// int r = taosThreadMutexInit(&p->lock, NULL);
|
||||
// do {
|
||||
// if (r) break;
|
||||
// r = taosThreadCondInit(&p->cond, NULL);
|
||||
// if (r) {
|
||||
// taosThreadMutexDestroy(&p->lock);
|
||||
// break;
|
||||
// }
|
||||
// p->val = value;
|
||||
// } while (0);
|
||||
// if (r) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==not created\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, sem);
|
||||
// abort();
|
||||
// }
|
||||
// #elif defined(SEM_USE_POSIX)
|
||||
// static size_t tick = 0;
|
||||
// do {
|
||||
// size_t id = atomic_add_fetch_64(&tick, 1);
|
||||
// if (id == SEM_VALUE_MAX) {
|
||||
// atomic_store_64(&tick, 0);
|
||||
// id = 0;
|
||||
// }
|
||||
// char name[NAME_MAX - 4];
|
||||
// snprintf(name, sizeof(name), "/t" PRId64, id);
|
||||
// p->sem = sem_open(name, O_CREAT | O_EXCL, pshared, value);
|
||||
// p->id = id;
|
||||
// if (p->sem != SEM_FAILED) break;
|
||||
// int e = errno;
|
||||
// if (e == EEXIST) continue;
|
||||
// if (e == EINTR) continue;
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==not created[%d]%s\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__,
|
||||
// sem,
|
||||
// e, strerror(e));
|
||||
// abort();
|
||||
// } while (p->sem == SEM_FAILED);
|
||||
// #elif defined(SEM_USE_SEM)
|
||||
// taosThreadOnce(&sem_once, once_init);
|
||||
// if (sem_inited != 1) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==internal resource init failed\n", taosDirEntryBaseName(__FILE__), __LINE__,
|
||||
// __func__, sem);
|
||||
// errno = ENOMEM;
|
||||
// return -1;
|
||||
// }
|
||||
// kern_return_t ret = semaphore_create(sem_port, &p->sem, SYNC_POLICY_FIFO, value);
|
||||
// if (ret != KERN_SUCCESS) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==semophore_create failed\n", taosDirEntryBaseName(__FILE__), __LINE__,
|
||||
// __func__,
|
||||
// sem);
|
||||
// // we fail-fast here, because we have less-doc about semaphore_create for the moment
|
||||
// abort();
|
||||
// }
|
||||
// #else // SEM_USE_PTHREAD
|
||||
// p->sem = dispatch_semaphore_create(value);
|
||||
// if (p->sem == NULL) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==not created\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, sem);
|
||||
// abort();
|
||||
// }
|
||||
// #endif // SEM_USE_PTHREAD
|
||||
|
||||
// p->valid = 1;
|
||||
|
||||
// *sem = p;
|
||||
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
// int tsem_wait(tsem_t *sem) {
|
||||
// if (!*sem) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==not initialized\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, sem);
|
||||
// abort();
|
||||
// }
|
||||
// struct tsem_s *p = *sem;
|
||||
// if (!p->valid) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==already destroyed\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__,
|
||||
// sem); abort();
|
||||
// }
|
||||
// #ifdef SEM_USE_PTHREAD
|
||||
// if (taosThreadMutexLock(&p->lock)) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__,
|
||||
// sem);
|
||||
// abort();
|
||||
// }
|
||||
// p->val -= 1;
|
||||
// if (p->val < 0) {
|
||||
// if (taosThreadCondWait(&p->cond, &p->lock)) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__,
|
||||
// __func__,
|
||||
// sem);
|
||||
// abort();
|
||||
// }
|
||||
// }
|
||||
// if (taosThreadMutexUnlock(&p->lock)) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__,
|
||||
// sem);
|
||||
// abort();
|
||||
// }
|
||||
// return 0;
|
||||
// #elif defined(SEM_USE_POSIX)
|
||||
// return sem_wait(p->sem);
|
||||
// #elif defined(SEM_USE_SEM)
|
||||
// return semaphore_wait(p->sem);
|
||||
// #else // SEM_USE_PTHREAD
|
||||
// return dispatch_semaphore_wait(p->sem, DISPATCH_TIME_FOREVER);
|
||||
// #endif // SEM_USE_PTHREAD
|
||||
// }
|
||||
|
||||
// int tsem_post(tsem_t *sem) {
|
||||
// if (!*sem) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==not initialized\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, sem);
|
||||
// abort();
|
||||
// }
|
||||
// struct tsem_s *p = *sem;
|
||||
// if (!p->valid) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==already destroyed\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__,
|
||||
// sem); abort();
|
||||
// }
|
||||
// #ifdef SEM_USE_PTHREAD
|
||||
// if (taosThreadMutexLock(&p->lock)) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__,
|
||||
// sem);
|
||||
// abort();
|
||||
// }
|
||||
// p->val += 1;
|
||||
// if (p->val <= 0) {
|
||||
// if (taosThreadCondSignal(&p->cond)) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__,
|
||||
// __func__,
|
||||
// sem);
|
||||
// abort();
|
||||
// }
|
||||
// }
|
||||
// if (taosThreadMutexUnlock(&p->lock)) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__,
|
||||
// sem);
|
||||
// abort();
|
||||
// }
|
||||
// return 0;
|
||||
// #elif defined(SEM_USE_POSIX)
|
||||
// return sem_post(p->sem);
|
||||
// #elif defined(SEM_USE_SEM)
|
||||
// return semaphore_signal(p->sem);
|
||||
// #else // SEM_USE_PTHREAD
|
||||
// return dispatch_semaphore_signal(p->sem);
|
||||
// #endif // SEM_USE_PTHREAD
|
||||
// }
|
||||
|
||||
// int tsem_destroy(tsem_t *sem) {
|
||||
// // fprintf(stderr, "==%s[%d]%s():[%p]==destroying\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__, sem);
|
||||
// if (!*sem) {
|
||||
// // fprintf(stderr, "==%s[%d]%s():[%p]==not initialized\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__,
|
||||
// sem);
|
||||
// // abort();
|
||||
// return 0;
|
||||
// }
|
||||
// struct tsem_s *p = *sem;
|
||||
// if (!p->valid) {
|
||||
// // fprintf(stderr, "==%s[%d]%s():[%p]==already destroyed\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__,
|
||||
// // sem); abort();
|
||||
// return 0;
|
||||
// }
|
||||
// #ifdef SEM_USE_PTHREAD
|
||||
// if (taosThreadMutexLock(&p->lock)) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__,
|
||||
// sem);
|
||||
// abort();
|
||||
// }
|
||||
// p->valid = 0;
|
||||
// if (taosThreadCondDestroy(&p->cond)) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__,
|
||||
// sem);
|
||||
// abort();
|
||||
// }
|
||||
// if (taosThreadMutexUnlock(&p->lock)) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__,
|
||||
// sem);
|
||||
// abort();
|
||||
// }
|
||||
// if (taosThreadMutexDestroy(&p->lock)) {
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==internal logic error\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__,
|
||||
// sem);
|
||||
// abort();
|
||||
// }
|
||||
// #elif defined(SEM_USE_POSIX)
|
||||
// char name[NAME_MAX - 4];
|
||||
// snprintf(name, sizeof(name), "/t" PRId64, p->id);
|
||||
// int r = sem_unlink(name);
|
||||
// if (r) {
|
||||
// int e = errno;
|
||||
// fprintf(stderr, "==%s[%d]%s():[%p]==unlink failed[%d]%s\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__,
|
||||
// sem,
|
||||
// e, strerror(e));
|
||||
// abort();
|
||||
// }
|
||||
// #elif defined(SEM_USE_SEM)
|
||||
// semaphore_destroy(sem_port, p->sem);
|
||||
// #else // SEM_USE_PTHREAD
|
||||
// #endif // SEM_USE_PTHREAD
|
||||
|
||||
// p->valid = 0;
|
||||
// taosMemoryFree(p);
|
||||
|
||||
// *sem = NULL;
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
int tsem_init(tsem_t *psem, int flags, unsigned int count) {
|
||||
*psem = dispatch_semaphore_create(count);
|
||||
if (*psem == NULL) return -1;
|
||||
|
@ -401,8 +116,8 @@ int tsem_init(tsem_t *psem, int flags, unsigned int count) {
|
|||
|
||||
int tsem_destroy(tsem_t *psem) {
|
||||
if (psem == NULL || *psem == NULL) return -1;
|
||||
dispatch_release(*psem);
|
||||
*psem = NULL;
|
||||
// dispatch_release(*psem);
|
||||
// *psem = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -312,14 +312,8 @@ uint32_t taosInetAddr(const char *ipAddr) {
|
|||
return inet_addr(ipAddr);
|
||||
#endif
|
||||
}
|
||||
const char *taosInetNtoa(struct in_addr ipInt) {
|
||||
#ifdef WINDOWS
|
||||
// not thread safe, only for debug usage while print log
|
||||
static char tmpDstStr[16];
|
||||
return inet_ntop(AF_INET, &ipInt, tmpDstStr, INET6_ADDRSTRLEN);
|
||||
#else
|
||||
return inet_ntoa(ipInt);
|
||||
#endif
|
||||
const char *taosInetNtoa(struct in_addr ipInt, char *dstStr, int32_t len) {
|
||||
return inet_ntop(AF_INET, &ipInt, dstStr, len);
|
||||
}
|
||||
|
||||
#ifndef SIGPIPE
|
||||
|
@ -670,7 +664,7 @@ int taosGetLocalIp(const char *eth, char *ip) {
|
|||
return -1;
|
||||
}
|
||||
memcpy(&sin, &ifr.ifr_addr, sizeof(sin));
|
||||
snprintf(ip, 64, "%s", inet_ntoa(sin.sin_addr));
|
||||
taosInetNtoa(sin.sin_addr, ip, 64);
|
||||
taosCloseSocketNoCheck1(fd);
|
||||
#endif
|
||||
return 0;
|
||||
|
|
|
@ -306,8 +306,6 @@ int32_t taosMbsToWchars(TdWchar *pWchars, const char *pStrs, int32_t size) { ret
|
|||
|
||||
int32_t taosWcharToMb(char *pStr, TdWchar wchar) { return wctomb(pStr, wchar); }
|
||||
|
||||
int32_t taosWcharsToMbs(char *pStrs, TdWchar *pWchars, int32_t size) { return wcstombs(pStrs, pWchars, size); }
|
||||
|
||||
char *taosStrCaseStr(const char *str, const char *pattern) {
|
||||
size_t i;
|
||||
|
||||
|
@ -326,6 +324,9 @@ char *taosStrCaseStr(const char *str, const char *pattern) {
|
|||
|
||||
int64_t taosStr2Int64(const char *str, char **pEnd, int32_t radix) {
|
||||
int64_t tmp = strtoll(str, pEnd, radix);
|
||||
#ifdef DARWIN
|
||||
if (errno == EINVAL) errno = 0;
|
||||
#endif
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
|
@ -335,6 +336,9 @@ int64_t taosStr2Int64(const char *str, char **pEnd, int32_t radix) {
|
|||
|
||||
uint64_t taosStr2UInt64(const char *str, char **pEnd, int32_t radix) {
|
||||
uint64_t tmp = strtoull(str, pEnd, radix);
|
||||
#ifdef DARWIN
|
||||
if (errno == EINVAL) errno = 0;
|
||||
#endif
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
|
@ -344,6 +348,9 @@ uint64_t taosStr2UInt64(const char *str, char **pEnd, int32_t radix) {
|
|||
|
||||
int32_t taosStr2Int32(const char *str, char **pEnd, int32_t radix) {
|
||||
int32_t tmp = strtol(str, pEnd, radix);
|
||||
#ifdef DARWIN
|
||||
if (errno == EINVAL) errno = 0;
|
||||
#endif
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
|
@ -353,6 +360,9 @@ int32_t taosStr2Int32(const char *str, char **pEnd, int32_t radix) {
|
|||
|
||||
uint32_t taosStr2UInt32(const char *str, char **pEnd, int32_t radix) {
|
||||
uint32_t tmp = strtol(str, pEnd, radix);
|
||||
#ifdef DARWIN
|
||||
if (errno == EINVAL) errno = 0;
|
||||
#endif
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
|
@ -362,6 +372,9 @@ uint32_t taosStr2UInt32(const char *str, char **pEnd, int32_t radix) {
|
|||
|
||||
int16_t taosStr2Int16(const char *str, char **pEnd, int32_t radix) {
|
||||
int32_t tmp = strtol(str, pEnd, radix);
|
||||
#ifdef DARWIN
|
||||
if (errno == EINVAL) errno = 0;
|
||||
#endif
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
|
@ -373,6 +386,9 @@ int16_t taosStr2Int16(const char *str, char **pEnd, int32_t radix) {
|
|||
|
||||
uint16_t taosStr2UInt16(const char *str, char **pEnd, int32_t radix) {
|
||||
uint32_t tmp = strtoul(str, pEnd, radix);
|
||||
#ifdef DARWIN
|
||||
if (errno == EINVAL) errno = 0;
|
||||
#endif
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
|
@ -394,6 +410,9 @@ int8_t taosStr2Int8(const char *str, char **pEnd, int32_t radix) {
|
|||
|
||||
uint8_t taosStr2UInt8(const char *str, char **pEnd, int32_t radix) {
|
||||
uint32_t tmp = strtoul(str, pEnd, radix);
|
||||
#ifdef DARWIN
|
||||
if (errno == EINVAL) errno = 0;
|
||||
#endif
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
|
|
|
@ -143,8 +143,11 @@ static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
|
|||
cpuInfo->user = CompareFileTime(&pre_userTime, &userTime);
|
||||
cpuInfo->nice = 0;
|
||||
}
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
assert(0);
|
||||
#elif defined(DARWIN)
|
||||
cpuInfo->idle = 0;
|
||||
cpuInfo->system = 0;
|
||||
cpuInfo->user = 0;
|
||||
cpuInfo->nice = 0;
|
||||
#else
|
||||
TdFilePtr pFile = taosOpenFile(tsSysCpuFile, TD_FILE_READ | TD_FILE_STREAM);
|
||||
if (pFile == NULL) {
|
||||
|
@ -180,8 +183,11 @@ static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
|
|||
cpuInfo->cutime = 0;
|
||||
cpuInfo->cstime = 0;
|
||||
}
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
assert(0);
|
||||
#elif defined(DARWIN)
|
||||
cpuInfo->stime = 0;
|
||||
cpuInfo->utime = 0;
|
||||
cpuInfo->cutime = 0;
|
||||
cpuInfo->cstime = 0;
|
||||
#else
|
||||
TdFilePtr pFile = taosOpenFile(tsProcCpuFile, TD_FILE_READ | TD_FILE_STREAM);
|
||||
if (pFile == NULL) {
|
||||
|
@ -359,7 +365,7 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
|
|||
pCmd = taosOpenCmd("sysctl -n machdep.cpu.core_count");
|
||||
if (pCmd == NULL) return code;
|
||||
memset(buf, 0, sizeof(buf));
|
||||
if (taosGetsCmd(pCmd, maxLen, cpuModel) > 0) {
|
||||
if (taosGetsCmd(pCmd, sizeof(buf) - 1, buf) > 0) {
|
||||
code = 0;
|
||||
done |= 2;
|
||||
*numOfCores = atof(buf);
|
||||
|
|
|
@ -891,6 +891,7 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) {
|
|||
time_t tx1 = taosGetTimestampSec();
|
||||
struct tm tm1;
|
||||
taosLocalTime(&tx1, &tm1);
|
||||
daylight = tm1.tm_isdst;
|
||||
|
||||
/*
|
||||
* format example:
|
||||
|
|
|
@ -415,23 +415,15 @@ class TDDnode:
|
|||
i += 1
|
||||
if i > 50:
|
||||
break
|
||||
tailCmdStr = 'tail -f '
|
||||
popen = subprocess.Popen(
|
||||
tailCmdStr + logFile,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
shell=True)
|
||||
pid = popen.pid
|
||||
# print('Popen.pid:' + str(pid))
|
||||
timeout = time.time() + 60 * 2
|
||||
while True:
|
||||
line = popen.stdout.readline().strip()
|
||||
if bkey in line:
|
||||
popen.kill()
|
||||
break
|
||||
if time.time() > timeout:
|
||||
tdLog.exit('wait too long for taosd start')
|
||||
tdLog.debug("the dnode:%d has been started." % (self.index))
|
||||
with open(logFile) as f:
|
||||
timeout = time.time() + 60 * 2
|
||||
while True:
|
||||
line = f.readline().encode('utf-8')
|
||||
if bkey in line:
|
||||
break
|
||||
if time.time() > timeout:
|
||||
tdLog.exit('wait too long for taosd start')
|
||||
tdLog.debug("the dnode:%d has been started." % (self.index))
|
||||
else:
|
||||
tdLog.debug(
|
||||
"wait 10 seconds for the dnode:%d to start." %
|
||||
|
@ -480,19 +472,21 @@ class TDDnode:
|
|||
toBeKilled = "valgrind.bin"
|
||||
|
||||
if self.running != 0:
|
||||
psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled
|
||||
psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs" % toBeKilled
|
||||
processID = subprocess.check_output(
|
||||
psCmd, shell=True).decode("utf-8")
|
||||
psCmd, shell=True).decode("utf-8").strip()
|
||||
|
||||
onlyKillOnceWindows = 0
|
||||
while(processID):
|
||||
if not platform.system().lower() == 'windows' or (onlyKillOnceWindows == 0 and platform.system().lower() == 'windows'):
|
||||
killCmd = "kill -INT %s > /dev/null 2>&1" % processID
|
||||
if platform.system().lower() == 'windows':
|
||||
killCmd = "kill -INT %s > nul 2>&1" % processID
|
||||
os.system(killCmd)
|
||||
onlyKillOnceWindows = 1
|
||||
time.sleep(1)
|
||||
processID = subprocess.check_output(
|
||||
psCmd, shell=True).decode("utf-8")
|
||||
psCmd, shell=True).decode("utf-8").strip()
|
||||
if not platform.system().lower() == 'windows':
|
||||
for port in range(6030, 6041):
|
||||
fuserCmd = "fuser -k -n tcp %d > /dev/null" % port
|
||||
|
@ -516,11 +510,11 @@ class TDDnode:
|
|||
|
||||
if self.running != 0:
|
||||
if platform.system().lower() == 'windows':
|
||||
psCmd = "for /f %%a in ('wmic process where \"name='taosd.exe' and CommandLine like '%%dnode%d%%'\" get processId ^| xargs echo ^| awk ^'{print $2}^' ^&^& echo aa') do @(ps | grep %%a | awk '{print $1}' )" % (self.index)
|
||||
psCmd = "for /f %%a in ('wmic process where \"name='taosd.exe' and CommandLine like '%%dnode%d%%'\" get processId ^| xargs echo ^| awk ^'{print $2}^' ^&^& echo aa') do @(ps | grep %%a | awk '{print $1}' | xargs)" % (self.index)
|
||||
else:
|
||||
psCmd = "ps -ef|grep -w %s| grep dnode%d|grep -v grep | awk '{print $2}'" % (toBeKilled,self.index)
|
||||
psCmd = "ps -ef|grep -w %s| grep dnode%d|grep -v grep | awk '{print $2}' | xargs" % (toBeKilled,self.index)
|
||||
processID = subprocess.check_output(
|
||||
psCmd, shell=True).decode("utf-8")
|
||||
psCmd, shell=True).decode("utf-8").strip()
|
||||
|
||||
onlyKillOnceWindows = 0
|
||||
while(processID):
|
||||
|
@ -530,7 +524,7 @@ class TDDnode:
|
|||
onlyKillOnceWindows = 1
|
||||
time.sleep(1)
|
||||
processID = subprocess.check_output(
|
||||
psCmd, shell=True).decode("utf-8")
|
||||
psCmd, shell=True).decode("utf-8").strip()
|
||||
if self.valgrind:
|
||||
time.sleep(2)
|
||||
|
||||
|
@ -547,9 +541,9 @@ class TDDnode:
|
|||
toBeKilled = "valgrind.bin"
|
||||
|
||||
if self.running != 0:
|
||||
psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled
|
||||
psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}' | xargs" % toBeKilled
|
||||
processID = subprocess.check_output(
|
||||
psCmd, shell=True).decode("utf-8")
|
||||
psCmd, shell=True).decode("utf-8").strip()
|
||||
|
||||
onlyKillOnceWindows = 0
|
||||
while(processID):
|
||||
|
@ -559,7 +553,7 @@ class TDDnode:
|
|||
onlyKillOnceWindows = 1
|
||||
time.sleep(1)
|
||||
processID = subprocess.check_output(
|
||||
psCmd, shell=True).decode("utf-8")
|
||||
psCmd, shell=True).decode("utf-8").strip()
|
||||
for port in range(6030, 6041):
|
||||
fuserCmd = "fuser -k -n tcp %d" % port
|
||||
os.system(fuserCmd)
|
||||
|
@ -704,15 +698,15 @@ class TDDnodes:
|
|||
for i in range(len(self.dnodes)):
|
||||
self.dnodes[i].stop()
|
||||
|
||||
psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}'"
|
||||
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8")
|
||||
psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}' | xargs"
|
||||
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip()
|
||||
if processID:
|
||||
cmd = "sudo systemctl stop taosd"
|
||||
os.system(cmd)
|
||||
# if os.system(cmd) != 0 :
|
||||
# tdLog.exit(cmd)
|
||||
psCmd = "ps -ef|grep -w taosd| grep -v grep| grep -v defunct | awk '{print $2}'"
|
||||
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8")
|
||||
psCmd = "ps -ef|grep -w taosd| grep -v grep| grep -v defunct | awk '{print $2}' | xargs"
|
||||
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip()
|
||||
while(processID):
|
||||
if platform.system().lower() == 'windows':
|
||||
killCmd = "kill -9 %s > nul 2>&1" % processID
|
||||
|
@ -721,11 +715,11 @@ class TDDnodes:
|
|||
os.system(killCmd)
|
||||
time.sleep(1)
|
||||
processID = subprocess.check_output(
|
||||
psCmd, shell=True).decode("utf-8")
|
||||
psCmd, shell=True).decode("utf-8").strip()
|
||||
|
||||
if self.killValgrind == 1:
|
||||
psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}'"
|
||||
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8")
|
||||
psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}' | xargs"
|
||||
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip()
|
||||
while(processID):
|
||||
if platform.system().lower() == 'windows':
|
||||
killCmd = "kill -TERM %s > nul 2>&1" % processID
|
||||
|
@ -734,7 +728,7 @@ class TDDnodes:
|
|||
os.system(killCmd)
|
||||
time.sleep(1)
|
||||
processID = subprocess.check_output(
|
||||
psCmd, shell=True).decode("utf-8")
|
||||
psCmd, shell=True).decode("utf-8").strip()
|
||||
|
||||
# if os.system(cmd) != 0 :
|
||||
# tdLog.exit(cmd)
|
||||
|
|
Loading…
Reference in New Issue