已合并
fix: 修复 CheckAndMkdir 多进程竞态条件及 TraceManager 日志语法 #3580
duhua创建于 6月16日
fix: 修复 CheckAndMkdir 多进程竞态条件及 TraceManager 日志语法 #3580
已合并
共 2 个文件变更+4-1
| @@ -77,6 +77,9 @@ static inline int32_t CheckAndMkdir(const char_t *tmp_dir_path, mmMode_t mode) { | |||
| 77 | if (mmAccess2(tmp_dir_path, M_F_OK) != EN_OK) { | 77 | if (mmAccess2(tmp_dir_path, M_F_OK) != EN_OK) { |
| 78 | const int32_t ret = mmMkdir(tmp_dir_path, mode); | 78 | const int32_t ret = mmMkdir(tmp_dir_path, mode); |
| 79 | if (ret != 0) { | 79 | if (ret != 0) { |
| 80 | + if (errno == EEXIST) { | ||
| 81 | + return 0; | ||
| 82 | + } | ||
| 80 | std::vector<char_t> err_buf(kMaxErrorStrLen + 1U, '\0'); | 83 | std::vector<char_t> err_buf(kMaxErrorStrLen + 1U, '\0'); |
| 81 | const auto err_msg = mmGetErrorFormatMessage(mmGetErrorCode(), err_buf.data(), kMaxErrorStrLen); | 84 | const auto err_msg = mmGetErrorFormatMessage(mmGetErrorCode(), err_buf.data(), kMaxErrorStrLen); |
| 82 | std::string reason = FormatErrnoReason(mmGetErrorCode(), err_msg); | 85 | std::string reason = FormatErrnoReason(mmGetErrorCode(), err_msg); |
| @@ -190,7 +190,7 @@ Status TraceManager::Initialize(const char_t *file_save_path) { | |||
| 190 | << MMPA_PATH_SEPARATOR_STR << ge::GetContext().DeviceId() << MMPA_PATH_SEPARATOR_STR; | 190 | << MMPA_PATH_SEPARATOR_STR << ge::GetContext().DeviceId() << MMPA_PATH_SEPARATOR_STR; |
| 191 | trace_save_file_path_ = ss.str(); | 191 | trace_save_file_path_ = ss.str(); |
| 192 | if (CreateDir(trace_save_file_path_) != 0) { | 192 | if (CreateDir(trace_save_file_path_) != 0) { |
| 193 | - GELOGE(INTERNAL_ERROR, "[trace] Trace not enabled as failed create trace file save directory[%s]", | 193 | + GELOGE(INTERNAL_ERROR, "[trace] Trace not enabled: failed to create trace file save directory[%s]", |
| 194 | trace_save_file_path_.c_str()); | 194 | trace_save_file_path_.c_str()); |
| 195 | return FAILED; | 195 | return FAILED; |
| 196 | } | 196 | } |