osDir
This commit is contained in:
parent
3825f76dfc
commit
520336e129
|
@ -821,9 +821,10 @@ int32_t monitorInit() {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosMulModeMkDir(tmpSlowLogPath, 0777, true) != 0) {
|
code = taosMulModeMkDir(tmpSlowLogPath, 0777, true);
|
||||||
|
if (code != 0) {
|
||||||
tscError("failed to create dir:%s since %s", tmpSlowLogPath, terrstr());
|
tscError("failed to create dir:%s since %s", tmpSlowLogPath, terrstr());
|
||||||
return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsem2_init(&monitorSem, 0, 0) != 0) {
|
if (tsem2_init(&monitorSem, 0, 0) != 0) {
|
||||||
|
|
|
@ -1881,7 +1881,6 @@ void s3EvictCache(const char *path, long object_size) {
|
||||||
// 1, list data files' atime under dir(path)
|
// 1, list data files' atime under dir(path)
|
||||||
tdbDirPtr pDir = taosOpenDir(dir_name);
|
tdbDirPtr pDir = taosOpenDir(dir_name);
|
||||||
if (pDir == NULL) {
|
if (pDir == NULL) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
vError("failed to open %s since %s", dir_name, terrstr());
|
vError("failed to open %s since %s", dir_name, terrstr());
|
||||||
}
|
}
|
||||||
SArray *evict_files = taosArrayInit(16, sizeof(SEvictFile));
|
SArray *evict_files = taosArrayInit(16, sizeof(SEvictFile));
|
||||||
|
|
|
@ -1125,7 +1125,7 @@ static int32_t tfileGetFileList(const char* path, SArray** ppResult) {
|
||||||
|
|
||||||
TdDirPtr pDir = taosOpenDir(path);
|
TdDirPtr pDir = taosOpenDir(path);
|
||||||
if (NULL == pDir) {
|
if (NULL == pDir) {
|
||||||
TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _exception);
|
TAOS_CHECK_GOTO(terrno, NULL, _exception);
|
||||||
}
|
}
|
||||||
TdDirEntryPtr pDirEntry;
|
TdDirEntryPtr pDirEntry;
|
||||||
while ((pDirEntry = taosReadDir(pDir)) != NULL) {
|
while ((pDirEntry = taosReadDir(pDir)) != NULL) {
|
||||||
|
|
|
@ -599,7 +599,7 @@ int32_t backendFileCopyFilesImpl(const char* src, const char* dst) {
|
||||||
// copy file to dst
|
// copy file to dst
|
||||||
TdDirPtr pDir = taosOpenDir(src);
|
TdDirPtr pDir = taosOpenDir(src);
|
||||||
if (pDir == NULL) {
|
if (pDir == NULL) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
goto _ERROR;
|
goto _ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1428,7 +1428,7 @@ int32_t chkpPreBuildDir(char* path, int64_t chkpId, char** chkpDir, char** chkpI
|
||||||
|
|
||||||
code = taosMulModeMkDir(pChkpDir, 0755, true);
|
code = taosMulModeMkDir(pChkpDir, 0755, true);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
stError("failed to prepare checkpoint dir, path:%s, reason:%s", path, tstrerror(code));
|
stError("failed to prepare checkpoint dir, path:%s, reason:%s", path, tstrerror(code));
|
||||||
goto _EXIT;
|
goto _EXIT;
|
||||||
}
|
}
|
||||||
|
@ -4633,7 +4633,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
|
||||||
TdDirPtr pDir = taosOpenDir(p->buf);
|
TdDirPtr pDir = taosOpenDir(p->buf);
|
||||||
if (pDir == NULL) {
|
if (pDir == NULL) {
|
||||||
(void)taosThreadRwlockUnlock(&p->rwLock);
|
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||||
return TAOS_SYSTEM_ERROR(errno);
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
TdDirEntryPtr de = NULL;
|
TdDirEntryPtr de = NULL;
|
||||||
|
|
|
@ -1224,7 +1224,7 @@ static int32_t uploadCheckpointToS3(const char* id, const char* path) {
|
||||||
|
|
||||||
TdDirPtr pDir = taosOpenDir(path);
|
TdDirPtr pDir = taosOpenDir(path);
|
||||||
if (pDir == NULL) {
|
if (pDir == NULL) {
|
||||||
return TAOS_SYSTEM_ERROR(errno);
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
TdDirEntryPtr de = NULL;
|
TdDirEntryPtr de = NULL;
|
||||||
|
|
|
@ -271,7 +271,7 @@ int32_t snapFileReadMeta(SBackendSnapFile2* pSnapFile) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
TdDirPtr pDir = taosOpenDir(pSnapFile->path);
|
TdDirPtr pDir = taosOpenDir(pSnapFile->path);
|
||||||
if (NULL == pDir) {
|
if (NULL == pDir) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = terrno;
|
||||||
stError("%s failed to open %s, reason:%s", STREAM_STATE_TRANSFER, pSnapFile->path, tstrerror(code));
|
stError("%s failed to open %s, reason:%s", STREAM_STATE_TRANSFER, pSnapFile->path, tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1136,7 +1136,7 @@ int tdbPagerRestoreJournals(SPager *pPager) {
|
||||||
tdbDirPtr pDir = taosOpenDir(pPager->pEnv->dbName);
|
tdbDirPtr pDir = taosOpenDir(pPager->pEnv->dbName);
|
||||||
if (pDir == NULL) {
|
if (pDir == NULL) {
|
||||||
tdbError("failed to open %s since %s", pPager->pEnv->dbName, strerror(errno));
|
tdbError("failed to open %s since %s", pPager->pEnv->dbName, strerror(errno));
|
||||||
return TAOS_SYSTEM_ERROR(errno);
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray *pTxnList = taosArrayInit(16, sizeof(int64_t));
|
SArray *pTxnList = taosArrayInit(16, sizeof(int64_t));
|
||||||
|
@ -1182,7 +1182,7 @@ int tdbPagerRollback(SPager *pPager) {
|
||||||
tdbDirPtr pDir = taosOpenDir(pPager->pEnv->dbName);
|
tdbDirPtr pDir = taosOpenDir(pPager->pEnv->dbName);
|
||||||
if (pDir == NULL) {
|
if (pDir == NULL) {
|
||||||
tdbError("failed to open %s since %s", pPager->pEnv->dbName, strerror(errno));
|
tdbError("failed to open %s since %s", pPager->pEnv->dbName, strerror(errno));
|
||||||
return terrno = TAOS_SYSTEM_ERROR(errno);
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((pDirEntry = tdbReadDir(pDir)) != NULL) {
|
while ((pDirEntry = tdbReadDir(pDir)) != NULL) {
|
||||||
|
|
|
@ -403,7 +403,7 @@ int32_t walCheckAndRepairMeta(SWal* pWal) {
|
||||||
regfree(&logRegPattern);
|
regfree(&logRegPattern);
|
||||||
regfree(&idxRegPattern);
|
regfree(&idxRegPattern);
|
||||||
wError("vgId:%d, path:%s, failed to open since %s", pWal->cfg.vgId, pWal->path, strerror(errno));
|
wError("vgId:%d, path:%s, failed to open since %s", pWal->cfg.vgId, pWal->path, strerror(errno));
|
||||||
TAOS_RETURN(TSDB_CODE_FAILED);
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* actualLog = taosArrayInit(8, sizeof(SWalFileInfo));
|
SArray* actualLog = taosArrayInit(8, sizeof(SWalFileInfo));
|
||||||
|
@ -422,7 +422,7 @@ int32_t walCheckAndRepairMeta(SWal* pWal) {
|
||||||
regfree(&idxRegPattern);
|
regfree(&idxRegPattern);
|
||||||
(void)taosCloseDir(&pDir);
|
(void)taosCloseDir(&pDir);
|
||||||
|
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
return terrno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,10 @@ int32_t taosMulMkDir(const char *dirname) {
|
||||||
char *pos = temp;
|
char *pos = temp;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
taosRealPath(dirname, temp, sizeof(temp));
|
code = taosRealPath(dirname, temp, sizeof(temp));
|
||||||
|
if(code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
if (temp[1] == ':') pos += 3;
|
if (temp[1] == ':') pos += 3;
|
||||||
#else
|
#else
|
||||||
(void)strcpy(temp, dirname);
|
(void)strcpy(temp, dirname);
|
||||||
|
@ -207,7 +210,10 @@ int32_t taosMulModeMkDir(const char *dirname, int mode, bool checkAccess) {
|
||||||
char *pos = temp;
|
char *pos = temp;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
taosRealPath(dirname, temp, sizeof(temp));
|
code = taosRealPath(dirname, temp, sizeof(temp));
|
||||||
|
if(code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
if (temp[1] == ':') pos += 3;
|
if (temp[1] == ':') pos += 3;
|
||||||
#else
|
#else
|
||||||
(void)strcpy(temp, dirname);
|
(void)strcpy(temp, dirname);
|
||||||
|
@ -430,6 +436,9 @@ TdDirPtr taosOpenDir(const char *dirname) {
|
||||||
HANDLE hFind;
|
HANDLE hFind;
|
||||||
|
|
||||||
TdDirPtr pDir = taosMemoryMalloc(sizeof(TdDir));
|
TdDirPtr pDir = taosMemoryMalloc(sizeof(TdDir));
|
||||||
|
if(pDir == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(szFind, dirname);
|
strcpy(szFind, dirname);
|
||||||
strcat(szFind, "\\*.*"); //利用通配符找这个目录下的所以文件,包括目录
|
strcat(szFind, "\\*.*"); //利用通配符找这个目录下的所以文件,包括目录
|
||||||
|
@ -437,6 +446,8 @@ TdDirPtr taosOpenDir(const char *dirname) {
|
||||||
pDir->hFind = FindFirstFile(szFind, &(pDir->dirEntry.findFileData));
|
pDir->hFind = FindFirstFile(szFind, &(pDir->dirEntry.findFileData));
|
||||||
if (INVALID_HANDLE_VALUE == pDir->hFind) {
|
if (INVALID_HANDLE_VALUE == pDir->hFind) {
|
||||||
taosMemoryFree(pDir);
|
taosMemoryFree(pDir);
|
||||||
|
DWORD errorCode = GetLastError();
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errorCode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return pDir;
|
return pDir;
|
||||||
|
@ -444,6 +455,11 @@ TdDirPtr taosOpenDir(const char *dirname) {
|
||||||
DIR *pDir = opendir(dirname);
|
DIR *pDir = opendir(dirname);
|
||||||
if (pDir == NULL) return NULL;
|
if (pDir == NULL) return NULL;
|
||||||
TdDirPtr dirPtr = (TdDirPtr)taosMemoryMalloc(sizeof(TdDir));
|
TdDirPtr dirPtr = (TdDirPtr)taosMemoryMalloc(sizeof(TdDir));
|
||||||
|
if (dirPtr == NULL) {
|
||||||
|
(void)closedir(pDir);
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
dirPtr->dirEntryPtr = (TdDirEntryPtr) & (dirPtr->dirEntry1);
|
dirPtr->dirEntryPtr = (TdDirEntryPtr) & (dirPtr->dirEntry1);
|
||||||
dirPtr->pDir = pDir;
|
dirPtr->pDir = pDir;
|
||||||
return dirPtr;
|
return dirPtr;
|
||||||
|
@ -506,22 +522,30 @@ char *taosGetDirEntryName(TdDirEntryPtr pDirEntry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t taosCloseDir(TdDirPtr *ppDir) {
|
int32_t taosCloseDir(TdDirPtr *ppDir) {
|
||||||
|
int32_t code = 0;
|
||||||
if (ppDir == NULL || *ppDir == NULL) {
|
if (ppDir == NULL || *ppDir == NULL) {
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
FindClose((*ppDir)->hFind);
|
if(!FindClose((*ppDir)->hFind)) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(GetLastError());
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
taosMemoryFree(*ppDir);
|
taosMemoryFree(*ppDir);
|
||||||
*ppDir = NULL;
|
*ppDir = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
#elif defined(DARWIN)
|
#elif defined(DARWIN)
|
||||||
closedir((*ppDir)->pDir);
|
code = closedir((*ppDir)->pDir);
|
||||||
|
if (-1 == code) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
taosMemoryFree(*ppDir);
|
taosMemoryFree(*ppDir);
|
||||||
*ppDir = NULL;
|
*ppDir = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
int32_t code = closedir((DIR *)*ppDir);
|
code = closedir((DIR *)*ppDir);
|
||||||
*ppDir = NULL;
|
*ppDir = NULL;
|
||||||
if (-1 == code) {
|
if (-1 == code) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
|
|
@ -1227,8 +1227,8 @@ static void checkRegexCache(void* param, void* tmrId) {
|
||||||
if(sRegexCache.exit) {
|
if(sRegexCache.exit) {
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
bool ret = taosTmrReset(checkRegexCache, REGEX_CACHE_CLEAR_TIME * 1000, param, sRegexCache.regexCacheTmr, &tmrId);
|
bool stopped = taosTmrReset(checkRegexCache, REGEX_CACHE_CLEAR_TIME * 1000, param, sRegexCache.regexCacheTmr, &tmrId);
|
||||||
if (!ret) {
|
if (stopped) {
|
||||||
uError("failed to reset regex cache timer");
|
uError("failed to reset regex cache timer");
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue