Merge remote-tracking branch 'origin/fix/TD-31073.2' into fix/TD-31073.3

This commit is contained in:
dapan1121 2024-07-25 08:58:07 +08:00
commit 2f284b252f
4 changed files with 12 additions and 7 deletions

View File

@ -1442,7 +1442,12 @@ int64_t taosGetsFile(TdFilePtr pFile, int32_t maxSize, char *__restrict buf) {
}
if (fgets(buf, maxSize, pFile->fp) == NULL) {
return 0;
if (feof(pFile->fp)) {
return 0;
} else {
terrno = TAOS_SYSTEM_ERROR(ferror(pFile->fp));
return terrno;
}
}
return strlen(buf);

View File

@ -538,7 +538,7 @@ static int32_t taosCntrGetCpuCores(float *numOfCores) {
goto _sys;
}
char qline[32] = {0};
if (taosGetsFile(pFile, sizeof(qline), qline) < 0) {
if (taosGetsFile(pFile, sizeof(qline), qline) <= 0) {
taosCloseFile(&pFile);
goto _sys;
}
@ -552,7 +552,7 @@ static int32_t taosCntrGetCpuCores(float *numOfCores) {
goto _sys;
}
char pline[32] = {0};
if (taosGetsFile(pFile, sizeof(pline), pline) < 0) {
if (taosGetsFile(pFile, sizeof(pline), pline) <= 0) {
taosCloseFile(&pFile);
goto _sys;
}
@ -713,7 +713,7 @@ int32_t taosGetProcMemory(int64_t *usedKB) {
char line[1024] = {0};
while (!taosEOFFile(pFile)) {
bytes = taosGetsFile(pFile, sizeof(line), line);
if (bytes < 0) {
if (bytes <= 0) {
break;
}
if (strstr(line, "VmRSS:") != NULL) {
@ -917,7 +917,7 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) {
char nouse0[200] = {0};
_bytes = taosGetsFile(pFile, sizeof(line), line);
if (_bytes < 0) {
if (_bytes <= 0) {
break;
}

View File

@ -1118,7 +1118,7 @@ void shellSourceFile(const char *file) {
}
char *line = taosMemoryMalloc(TSDB_MAX_ALLOWED_SQL_LEN + 1);
while ((read_len = taosGetsFile(pFile, TSDB_MAX_ALLOWED_SQL_LEN, line)) != -1) {
while ((read_len = taosGetsFile(pFile, TSDB_MAX_ALLOWED_SQL_LEN, line)) > 0) {
if ( cmd_len + read_len >= TSDB_MAX_ALLOWED_SQL_LEN) {
printf("read command line too long over 1M, ignore this line. cmd_len = %d read_len=%d \n", (int32_t)cmd_len, read_len);
cmd_len = 0;

View File

@ -198,7 +198,7 @@ SScript *simParseScript(char *fileName) {
simResetParser();
while (!taosEOFFile(pFile)) {
if (taosGetsFile(pFile, sizeof(buffer) - 1, buffer) == -1) continue;
if (taosGetsFile(pFile, sizeof(buffer) - 1, buffer) <= 0) continue;
lineNum++;
int32_t cmdlen = (int32_t)strlen(buffer);