os: add dll check
This commit is contained in:
parent
fd9bb8db73
commit
528d7d7248
|
@ -68,6 +68,7 @@ typedef struct {
|
|||
} SysNameInfo;
|
||||
|
||||
SysNameInfo taosGetSysNameInfo();
|
||||
bool taosCheckCurrentInDll();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -588,7 +588,9 @@ void hbThreadFuncUnexpectedStopped(void) {
|
|||
static void *hbThreadFunc(void *param) {
|
||||
setThreadName("hb");
|
||||
#ifdef WINDOWS
|
||||
atexit(hbThreadFuncUnexpectedStopped);
|
||||
if (taosCheckCurrentInDll()) {
|
||||
atexit(hbThreadFuncUnexpectedStopped);
|
||||
}
|
||||
#endif
|
||||
while (1) {
|
||||
int8_t threadStop = atomic_val_compare_exchange_8(&clientHbMgr.threadStop, 1, 2);
|
||||
|
|
|
@ -1938,7 +1938,9 @@ void ctgCleanupCacheQueue(void) {
|
|||
void* ctgUpdateThreadFunc(void* param) {
|
||||
setThreadName("catalog");
|
||||
#ifdef WINDOWS
|
||||
atexit(ctgUpdateThreadUnexpectedStopped);
|
||||
if (taosCheckCurrentInDll()) {
|
||||
atexit(ctgUpdateThreadUnexpectedStopped);
|
||||
}
|
||||
#endif
|
||||
qInfo("catalog update thread started");
|
||||
|
||||
|
|
|
@ -945,3 +945,19 @@ SysNameInfo taosGetSysNameInfo() {
|
|||
return info;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool taosCheckCurrentInDll() {
|
||||
#ifdef WINDOWS
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
char path[PATH_MAX] = {0};
|
||||
GetModuleFileName(((VirtualQuery(taosCheckCurrentInDll,&mbi,sizeof(mbi)) != 0) ? (HMODULE)mbi.AllocationBase : NULL), path, PATH_MAX);
|
||||
int strLastIndex = strlen(path);
|
||||
if ((path[strLastIndex-3] == 'd' || path[strLastIndex-3] == 'D') && (path[strLastIndex-2] == 'l' || path[strLastIndex-2] == 'L') && (path[strLastIndex-1] == 'l' || path[strLastIndex-1] == 'L')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
|
@ -829,7 +829,11 @@ void *taosCacheTimedRefresh(void *handle) {
|
|||
|
||||
const int32_t SLEEP_DURATION = 500; // 500 ms
|
||||
int64_t count = 0;
|
||||
atexit(taosCacheRefreshWorkerUnexpectedStopped);
|
||||
#ifdef WINDOWS
|
||||
if (taosCheckCurrentInDll()) {
|
||||
atexit(taosCacheRefreshWorkerUnexpectedStopped);
|
||||
}
|
||||
#endif
|
||||
|
||||
while (1) {
|
||||
taosMsleep(SLEEP_DURATION);
|
||||
|
|
Loading…
Reference in New Issue