mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-25 08:00:22 +00:00
Address code review feedback: retry loop, comment cleanup, error code improvements
Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/629eace2-9c23-40d9-89f5-9ef3099cdf14 Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
5e6d8a4692
commit
9a221d1291
@@ -35,7 +35,7 @@ getFileContents(
|
||||
|
||||
if (!fileStream)
|
||||
{
|
||||
ec = make_error_code(static_cast<std::errc>(errno));
|
||||
ec.assign(errno, std::generic_category());
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ getFileContents(
|
||||
|
||||
if (fileStream.bad())
|
||||
{
|
||||
ec = make_error_code(static_cast<std::errc>(errno));
|
||||
ec.assign(errno, std::generic_category());
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
{
|
||||
// Test with small max
|
||||
auto const bad = getFileContents(ec, path, 16);
|
||||
BEAST_EXPECT(ec && ec.value() == static_cast<int>(std::errc::file_too_large));
|
||||
BEAST_EXPECT(ec && ec == std::errc::file_too_large);
|
||||
BEAST_EXPECT(bad.empty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,9 +475,21 @@ SHAMapStoreImp::makeBackendRotating(std::string path)
|
||||
{
|
||||
std::filesystem::path const p = get(section, "path");
|
||||
std::random_device rd;
|
||||
std::ostringstream oss;
|
||||
oss << std::hex << std::setfill('0') << std::setw(8) << rd() << std::setw(8) << rd();
|
||||
newPath = (p / dbPrefix_).string() + "." + oss.str();
|
||||
constexpr std::size_t maxAttempts = 100;
|
||||
for (std::size_t attempt = 0; attempt < maxAttempts; ++attempt)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << std::hex << std::setfill('0') << std::setw(8) << rd() << std::setw(8) << rd();
|
||||
auto const candidate =
|
||||
std::filesystem::path((p / dbPrefix_).string() + "." + oss.str());
|
||||
if (!std::filesystem::exists(candidate))
|
||||
{
|
||||
newPath = candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newPath.empty())
|
||||
Throw<std::runtime_error>("Unable to generate a unique rotating backend path");
|
||||
}
|
||||
section.set("path", newPath.string());
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <xrpl/rdb/DatabaseCon.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem> // VFALCO FIX: This include should not be here
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
|
||||
Reference in New Issue
Block a user