Skip to content

Commit b513313

Browse files
authored
Merge pull request #28195 from taosdata/fix/ostime/mem
fix: ostime
2 parents 981777c + bac7820 commit b513313

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

source/libs/catalog/src/ctgCache.c

+9-3
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ int32_t ctgEnqueue(SCatalog *pCtg, SCtgCacheOperation *operation) {
906906
if (gCtgMgmt.queue.stopQueue) {
907907
ctgFreeQNode(node);
908908
CTG_UNLOCK(CTG_WRITE, &gCtgMgmt.queue.qlock);
909-
CTG_RET(TSDB_CODE_CTG_EXIT);
909+
CTG_ERR_JRET(TSDB_CODE_CTG_EXIT);
910910
}
911911

912912
gCtgMgmt.queue.tail->next = node;
@@ -924,7 +924,7 @@ int32_t ctgEnqueue(SCatalog *pCtg, SCtgCacheOperation *operation) {
924924
code = tsem_post(&gCtgMgmt.queue.reqSem);
925925
if (TSDB_CODE_SUCCESS != code) {
926926
qError("tsem_post failed, code:%x", code);
927-
CTG_RET(code);
927+
CTG_ERR_JRET(code);
928928
}
929929

930930
if (syncOp) {
@@ -935,9 +935,15 @@ int32_t ctgEnqueue(SCatalog *pCtg, SCtgCacheOperation *operation) {
935935
if (!operation->unLocked) {
936936
CTG_LOCK(CTG_READ, &gCtgMgmt.lock);
937937
}
938-
taosMemoryFree(operation);
938+
TAOS_UNUSED(tsem_destroy(&operation->rspSem));
939+
taosMemoryFreeClear(operation);
939940
}
941+
return code;
940942

943+
_return:
944+
if (syncOp && operation) {
945+
TAOS_UNUSED(tsem_destroy(&operation->rspSem));
946+
}
941947
return code;
942948
}
943949

source/os/src/osTimezone.c

+20-2
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,20 @@ char *tz_win[554][2] = {{"Asia/Shanghai", "China Standard Time"},
742742

743743
static int isdst_now = 0;
744744

745+
void parseTimeStr(char *p, char to[5]) {
746+
for (int i = 0; i < 5; ++i) {
747+
if (strlen(p) > i) {
748+
to[i] = p[i];
749+
} else {
750+
to[i] = '0';
751+
}
752+
}
753+
if (strlen(p) == 2) {
754+
to[1] = '0';
755+
to[2] = p[1];
756+
}
757+
}
758+
745759
int32_t taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, int8_t *outDaylight,
746760
enum TdTimezone *tsTimezone) {
747761
if (inTimezoneStr == NULL || inTimezoneStr[0] == 0) {
@@ -798,15 +812,19 @@ int32_t taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, i
798812
memcpy(&winStr[3], pp, ppp - pp);
799813
indexStr = ppp - pp + 3;
800814
}
801-
sprintf(&winStr[indexStr], "%c%c%c:%c%c:00", (p[0] == '+' ? '+' : '-'), p[1], p[2], p[3], p[4]);
815+
char to[5];
816+
parseTimeStr(p, to);
817+
sprintf(&winStr[indexStr], "%c%c%c:%c%c:00", (to[0] == '+' ? '+' : '-'), to[1], to[2], to[3], to[4]);
802818
*tsTimezone = -taosStr2Int32(p, NULL, 10);
803819
} else {
804820
*tsTimezone = 0;
805821
}
806822
}
807823
_putenv(winStr);
808824
_tzset();
809-
strcpy(outTimezoneStr, inTimezoneStr);
825+
if (outTimezoneStr != inTimezoneStr) {
826+
strcpy(outTimezoneStr, inTimezoneStr);
827+
}
810828
*outDaylight = 0;
811829

812830
#elif defined(_TD_DARWIN_64)

0 commit comments

Comments
 (0)