提交 2dfcac40 编写于 作者: S Shengliang Guan

TD-1057 change pthread_t to int64

上级 d4f39548
...@@ -32,6 +32,7 @@ extern "C" { ...@@ -32,6 +32,7 @@ extern "C" {
bool taosCheckPthreadValid(pthread_t thread); bool taosCheckPthreadValid(pthread_t thread);
int64_t taosGetPthreadId(); int64_t taosGetPthreadId();
void taosResetPthread(pthread_t *thread); void taosResetPthread(pthread_t *thread);
bool taosComparePthread(pthread_t first, pthread_t second);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -21,5 +21,6 @@ ...@@ -21,5 +21,6 @@
bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; } bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; }
int64_t taosGetPthreadId() { return (int64_t)pthread_self(); } int64_t taosGetPthreadId() { return (int64_t)pthread_self(); }
void taosResetPthread(pthread_t *thread) { *thread = 0; } void taosResetPthread(pthread_t *thread) { *thread = 0; }
bool taosComparePthread(pthread_t first, pthread_t second) { return first == second; }
#endif #endif
\ No newline at end of file
...@@ -32,3 +32,7 @@ int64_t taosGetPthreadId() { ...@@ -32,3 +32,7 @@ int64_t taosGetPthreadId() {
return (int64_t)pthread_self(); return (int64_t)pthread_self();
#endif #endif
} }
bool taosComparePthread(pthread_t first, pthread_t second) {
return first.p == second.p;
}
...@@ -186,7 +186,7 @@ enum { ...@@ -186,7 +186,7 @@ enum {
typedef struct SQInfo { typedef struct SQInfo {
void* signature; void* signature;
int32_t code; // error code to returned to client int32_t code; // error code to returned to client
pthread_t owner; // if it is in execution int64_t owner; // if it is in execution
void* tsdb; void* tsdb;
int32_t vgId; int32_t vgId;
STableGroupInfo tableGroupInfo; // table id list < only includes the STable list> STableGroupInfo tableGroupInfo; // table id list < only includes the STable list>
......
...@@ -130,8 +130,8 @@ static void finalizeQueryResult(SQueryRuntimeEnv *pRuntimeEnv); ...@@ -130,8 +130,8 @@ static void finalizeQueryResult(SQueryRuntimeEnv *pRuntimeEnv);
(tw)->ekey = (tw)->skey + ((_q)->intervalTime - 1); \ (tw)->ekey = (tw)->skey + ((_q)->intervalTime - 1); \
} while (0) } while (0)
#define SET_STABLE_QUERY_OVER(_q) ((_q)->tableIndex = (_q)->tableqinfoGroupInfo.numOfTables) #define SET_STABLE_QUERY_OVER(_q) ((_q)->tableIndex = (int32_t)((_q)->tableqinfoGroupInfo.numOfTables))
#define IS_STASBLE_QUERY_OVER(_q) ((_q)->tableIndex >= (_q)->tableqinfoGroupInfo.numOfTables) #define IS_STASBLE_QUERY_OVER(_q) ((_q)->tableIndex >= (int32_t)((_q)->tableqinfoGroupInfo.numOfTables))
// todo move to utility // todo move to utility
static int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *group); static int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *group);
...@@ -6378,8 +6378,8 @@ static bool doBuildResCheck(SQInfo* pQInfo) { ...@@ -6378,8 +6378,8 @@ static bool doBuildResCheck(SQInfo* pQInfo) {
pthread_mutex_unlock(&pQInfo->lock); pthread_mutex_unlock(&pQInfo->lock);
// clear qhandle owner // clear qhandle owner
assert(pQInfo->owner == pthread_self()); assert(pQInfo->owner == taosGetPthreadId());
taosResetPthread(&pQInfo->owner); pQInfo->owner = 0;
return buildRes; return buildRes;
} }
...@@ -6387,7 +6387,7 @@ static bool doBuildResCheck(SQInfo* pQInfo) { ...@@ -6387,7 +6387,7 @@ static bool doBuildResCheck(SQInfo* pQInfo) {
bool qTableQuery(qinfo_t qinfo) { bool qTableQuery(qinfo_t qinfo) {
SQInfo *pQInfo = (SQInfo *)qinfo; SQInfo *pQInfo = (SQInfo *)qinfo;
assert(pQInfo && pQInfo->signature == pQInfo); assert(pQInfo && pQInfo->signature == pQInfo);
int64_t threadId = pthread_self(); int64_t threadId = taosGetPthreadId();
int64_t curOwner = 0; int64_t curOwner = 0;
if ((curOwner = atomic_val_compare_exchange_64(&pQInfo->owner, 0, threadId)) != 0) { if ((curOwner = atomic_val_compare_exchange_64(&pQInfo->owner, 0, threadId)) != 0) {
...@@ -6549,7 +6549,7 @@ int32_t qKillQuery(qinfo_t qinfo) { ...@@ -6549,7 +6549,7 @@ int32_t qKillQuery(qinfo_t qinfo) {
// Wait for the query executing thread being stopped/ // Wait for the query executing thread being stopped/
// Once the query is stopped, the owner of qHandle will be cleared immediately. // Once the query is stopped, the owner of qHandle will be cleared immediately.
while (taosCheckPthreadValid(pQInfo->owner)) { while (pQInfo->owner != 0) {
taosMsleep(100); taosMsleep(100);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册