clear timer
This commit is contained in:
parent
3e85d0c546
commit
22f69837b3
|
@ -1211,7 +1211,7 @@ typedef struct UsingRegex {
|
||||||
|
|
||||||
typedef struct RegexCache {
|
typedef struct RegexCache {
|
||||||
SHashObj *regexHash;
|
SHashObj *regexHash;
|
||||||
void *regexCacheTimer;
|
void *regexCacheTmr;
|
||||||
void *timer;
|
void *timer;
|
||||||
} RegexCache;
|
} RegexCache;
|
||||||
static RegexCache sRegexCache;
|
static RegexCache sRegexCache;
|
||||||
|
@ -1219,7 +1219,7 @@ static RegexCache sRegexCache;
|
||||||
#define REGEX_CACHE_CLEAR_TIME 30
|
#define REGEX_CACHE_CLEAR_TIME 30
|
||||||
|
|
||||||
static void checkRegexCache(void* param, void* tmrId) {
|
static void checkRegexCache(void* param, void* tmrId) {
|
||||||
taosTmrReset(checkRegexCache, REGEX_CACHE_CLEAR_TIME * 1000, param, NULL, &tmrId);
|
taosTmrReset(checkRegexCache, REGEX_CACHE_CLEAR_TIME * 1000, param, sRegexCache.regexCacheTmr, &tmrId);
|
||||||
if (taosHashGetSize(sRegexCache.regexHash) < MAX_REGEX_CACHE_SIZE) {
|
if (taosHashGetSize(sRegexCache.regexHash) < MAX_REGEX_CACHE_SIZE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1236,6 +1236,7 @@ static void checkRegexCache(void* param, void* tmrId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void regexCacheFree(void *ppUsingRegex) {
|
void regexCacheFree(void *ppUsingRegex) {
|
||||||
|
uInfo("[regex cache] regexCacheFree %p", ppUsingRegex);
|
||||||
regfree(&(*(UsingRegex **)ppUsingRegex)->pRegex);
|
regfree(&(*(UsingRegex **)ppUsingRegex)->pRegex);
|
||||||
taosMemoryFree(*(UsingRegex **)ppUsingRegex);
|
taosMemoryFree(*(UsingRegex **)ppUsingRegex);
|
||||||
}
|
}
|
||||||
|
@ -1247,14 +1248,14 @@ int32_t InitRegexCache() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
taosHashSetFreeFp(sRegexCache.regexHash, regexCacheFree);
|
taosHashSetFreeFp(sRegexCache.regexHash, regexCacheFree);
|
||||||
sRegexCache.regexCacheTimer = taosTmrInit(0, 0, 0, "REGEXCACHE");
|
sRegexCache.regexCacheTmr = taosTmrInit(0, 0, 0, "REGEXCACHE");
|
||||||
if (sRegexCache.regexCacheTimer == NULL) {
|
if (sRegexCache.regexCacheTmr == NULL) {
|
||||||
uError("failed to create regex cache check timer");
|
uError("failed to create regex cache check timer");
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sRegexCache.timer = taosTmrStart(checkRegexCache, REGEX_CACHE_CLEAR_TIME * 1000, NULL, sRegexCache.regexCacheTimer);
|
sRegexCache.timer = taosTmrStart(checkRegexCache, REGEX_CACHE_CLEAR_TIME * 1000, NULL, sRegexCache.regexCacheTmr);
|
||||||
if (sRegexCache.timer == NULL) {
|
if (sRegexCache.timer == NULL) {
|
||||||
uError("failed to start regex cache timer");
|
uError("failed to start regex cache timer");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1264,8 +1265,10 @@ int32_t InitRegexCache() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyRegexCache(){
|
void DestroyRegexCache(){
|
||||||
|
uInfo("[regex cache] destory regex cache");
|
||||||
taosTmrStopA(&sRegexCache.timer);
|
taosTmrStopA(&sRegexCache.timer);
|
||||||
taosHashCleanup(sRegexCache.regexHash);
|
taosHashCleanup(sRegexCache.regexHash);
|
||||||
|
taosTmrCleanUp(sRegexCache.regexCacheTmr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t checkRegexPattern(const char *pPattern) {
|
int32_t checkRegexPattern(const char *pPattern) {
|
||||||
|
|
Loading…
Reference in New Issue