Improve:Ipc config module.

This commit is contained in:
Fancy code 2024-05-23 22:02:19 +08:00
parent 9c371dfe19
commit 69e69ba86e

View File

@ -14,6 +14,9 @@
*/ */
#include "IpcConfigImpl.h" #include "IpcConfigImpl.h"
#include "ILog.h" #include "ILog.h"
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#define CHECK_MAP(map) (map.size() == 1 ? true : false) #define CHECK_MAP(map) (map.size() == 1 ? true : false)
@ -463,10 +466,12 @@ void IpcConfigImpl::ReadingConfigThread(void)
*lastSlash = '\0'; *lastSlash = '\0';
} }
mThreadRuning = true; mThreadRuning = true;
DIR *dir = nullptr;
LogInfo("Reading config thread is running.dirPath = %s\n", dirPath); LogInfo("Reading config thread is running.dirPath = %s\n", dirPath);
while (mThreadRuning) { while (mThreadRuning) {
constexpr int FIEL_EXIST = 0; dir = opendir(dirPath);
if (FIEL_EXIST == access(dirPath, F_OK)) { if (nullptr != dir) {
closedir(dir);
memset(&mAllData, 0, sizeof(Config_s)); memset(&mAllData, 0, sizeof(Config_s));
mCfg = OpenConfigFile(IPC_CONFIG_FILE_PATH); mCfg = OpenConfigFile(IPC_CONFIG_FILE_PATH);
if (nullptr == mCfg) { if (nullptr == mCfg) {