Merge pull request #11197 from taosdata/fix/ZhiqiangWang/TD-13756-log-file-open-fail-error

[TD-13756]<fix>: log file open fail error.
This commit is contained in:
Zhiqiang Wang 2022-04-02 11:15:02 +08:00 committed by GitHub
commit cd650f7204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -347,12 +347,16 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
taosThreadMutexInit(&tsLogObj.logMutex, NULL);
taosUmaskFile(0);
tsLogObj.logHandle->pFile = taosOpenFile(fileName, TD_FILE_CTEATE | TD_FILE_WRITE);
TdFilePtr pFile = taosOpenFile(fileName, TD_FILE_CTEATE | TD_FILE_WRITE);
if (tsLogObj.logHandle->pFile == NULL) {
if (pFile == NULL) {
printf("\nfailed to open log file:%s, reason:%s\n", fileName, strerror(errno));
return -1;
}
TdFilePtr pOldFile = tsLogObj.logHandle->pFile;
tsLogObj.logHandle->pFile = pFile;
taosUnLockLogFile(pOldFile);
taosCloseFile(&pOldFile);
taosLockLogFile(tsLogObj.logHandle->pFile);
// only an estimate for number of lines