Merge pull request #28185 from taosdata/fix/ostime/mem

fix: ostime
This commit is contained in:
Pan Wei 2024-10-08 08:43:11 +08:00 committed by GitHub
commit cd2b053b85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 5 deletions

View File

@ -906,7 +906,7 @@ int32_t ctgEnqueue(SCatalog *pCtg, SCtgCacheOperation *operation) {
if (gCtgMgmt.queue.stopQueue) {
ctgFreeQNode(node);
CTG_UNLOCK(CTG_WRITE, &gCtgMgmt.queue.qlock);
CTG_RET(TSDB_CODE_CTG_EXIT);
CTG_ERR_JRET(TSDB_CODE_CTG_EXIT);
}
gCtgMgmt.queue.tail->next = node;
@ -924,7 +924,7 @@ int32_t ctgEnqueue(SCatalog *pCtg, SCtgCacheOperation *operation) {
code = tsem_post(&gCtgMgmt.queue.reqSem);
if (TSDB_CODE_SUCCESS != code) {
qError("tsem_post failed, code:%x", code);
CTG_RET(code);
CTG_ERR_JRET(code);
}
if (syncOp) {
@ -935,9 +935,15 @@ int32_t ctgEnqueue(SCatalog *pCtg, SCtgCacheOperation *operation) {
if (!operation->unLocked) {
CTG_LOCK(CTG_READ, &gCtgMgmt.lock);
}
taosMemoryFree(operation);
TAOS_UNUSED(tsem_destroy(&operation->rspSem));
taosMemoryFreeClear(operation);
}
return code;
_return:
if (syncOp && operation) {
TAOS_UNUSED(tsem_destroy(&operation->rspSem));
}
return code;
}

View File

@ -742,6 +742,20 @@ char *tz_win[554][2] = {{"Asia/Shanghai", "China Standard Time"},
static int isdst_now = 0;
void parseTimeStr(char *p, char to[5]) {
for (int i = 0; i < 5; ++i) {
if (strlen(p) > i) {
to[i] = p[i];
} else {
to[i] = '0';
}
}
if (strlen(p) == 2) {
to[1] = '0';
to[2] = p[1];
}
}
int32_t taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, int8_t *outDaylight,
enum TdTimezone *tsTimezone) {
if (inTimezoneStr == NULL || inTimezoneStr[0] == 0) {
@ -798,7 +812,9 @@ int32_t taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, i
memcpy(&winStr[3], pp, ppp - pp);
indexStr = ppp - pp + 3;
}
sprintf(&winStr[indexStr], "%c%c%c:%c%c:00", (p[0] == '+' ? '+' : '-'), p[1], p[2], p[3], p[4]);
char to[5];
parseTimeStr(p, to);
sprintf(&winStr[indexStr], "%c%c%c:%c%c:00", (to[0] == '+' ? '+' : '-'), to[1], to[2], to[3], to[4]);
*tsTimezone = -taosStr2Int32(p, NULL, 10);
} else {
*tsTimezone = 0;
@ -806,7 +822,9 @@ int32_t taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, i
}
_putenv(winStr);
_tzset();
if (outTimezoneStr != inTimezoneStr) {
strcpy(outTimezoneStr, inTimezoneStr);
}
*outDaylight = 0;
#elif defined(_TD_DARWIN_64)