Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions ucm/store/pcstore/cc/domain/file/posix_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@ PosixFile::~PosixFile() { this->Close(); }

Status PosixFile::MkDir()
{
constexpr auto permission = (S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IROTH);
constexpr auto permission = (S_IRWXU | S_IRWXG | S_IROTH);
auto ret = mkdir(this->Path().c_str(), permission);
auto eno = errno;
if (ret != 0) {
if (eno == EEXIST) {
return Status::DuplicateKey();
} else {
UC_ERROR("Failed to create directory, path: {}, errcode: {}, errno: {}.", this->Path(),
ret, eno);
return Status::OsApiError();
}
if (eno == EEXIST) { return Status::DuplicateKey(); }
UC_ERROR("Failed({},{}) to create dir({}).", ret, eno, this->Path());
return Status::OsApiError();
}
ret = chmod(this->Path().c_str(), permission);
eno = errno;
if (ret != 0) { UC_WARN("Failed({},{}) to set perm on dir({}).", ret, eno, this->Path()); }
return Status::OK();
}

Expand Down
22 changes: 11 additions & 11 deletions ucm/store/pcstore/cc/domain/trans/share_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,11 @@ std::shared_ptr<ShareBuffer::Reader> ShareBuffer::MakeLocalReader(const std::str
UC_ERROR("Failed to make buffer({}) on host.", blockSize_);
return nullptr;
}
Reader* reader = nullptr;
try {
reader = new Reader{block, path, blockSize_, ioDirect_, false, addr.get()};
return std::shared_ptr<Reader>(reader,
[addr = std::move(addr)](Reader* reader) { delete reader; });
return std::shared_ptr<Reader>(
new Reader{block, path, blockSize_, ioDirect_, false, addr.get()},
[addr = std::move(addr)](Reader* reader) { delete reader; });
} catch (const std::exception& e) {
if (reader) { delete reader; }
UC_ERROR("Failed({}) to create reader.", e.what());
return nullptr;
}
Expand All @@ -331,17 +329,19 @@ std::shared_ptr<ShareBuffer::Reader> ShareBuffer::MakeSharedReader(const std::st
size_t position)
{
void* addr = this->BlockAt(position);
Reader* reader = nullptr;
auto reader = new (std::nothrow) Reader(block, path, blockSize_, ioDirect_, true, addr);
if (!reader) [[unlikely]] {
this->ReleaseBlock(position);
UC_ERROR("Failed to create reader.");
return nullptr;
}
try {
reader = new Reader{block, path, blockSize_, ioDirect_, true, addr};
return std::shared_ptr<Reader>(reader, [this, position](Reader* reader) {
delete reader;
this->ReleaseBlock(position);
});
} catch (...) {
this->ReleaseBlock(position);
if (reader) { delete reader; }
UC_ERROR("Failed to create reader.");
} catch (const std::exception& e) {
UC_ERROR("Failed({}) to create reader.", e.what());
return nullptr;
}
}
Expand Down