Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ports just before usage. Use network specific folders. #3102

Merged
merged 1 commit into from
Oct 24, 2024
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
5 changes: 3 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,8 +1053,6 @@ void InitLogging()
version_string += " (release build)";
#endif
LogPrintf(PACKAGE_NAME " version %s\n", version_string);
// Remove ports.lock on startup in case of an unclean shutdown.
RemovePortUsage();
}

namespace { // Variables internal to initialization process only
Expand Down Expand Up @@ -1829,6 +1827,9 @@ bool AppInitMain(InitInterfaces& interfaces)
RegisterZMQRPCCommands(tableRPC);
#endif

// Remove ports.lock on startup in case of an unclean shutdown.
RemovePortUsage();

/* Start the RPC server already. It will be started in "warmup" mode
* and not really process calls already (but it will signify connections
* that the server is there and will be ready later). Warmup mode will
Expand Down
6 changes: 3 additions & 3 deletions src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ static std::string GetAutoPortString(const AutoPort type)

uint16_t GetPortFromLockFile(const AutoPort type)
{
const fs::path lockFilePath = GetDataDir() / "ports.lock";
const fs::path lockFilePath = GetDataDir(true) / "ports.lock";
const std::string portTypeStr = GetAutoPortString(type);

std::ifstream lockFile(lockFilePath);
Expand Down Expand Up @@ -376,7 +376,7 @@ void SetPortToLockFile(const AutoPort portType, const uint16_t portNumber)
return;
}

const fs::path lockFilePath = GetDataDir() / "ports.lock";
const fs::path lockFilePath = GetDataDir(true) / "ports.lock";

std::ofstream lockFile(lockFilePath, std::ios_base::app);
if (!lockFile.is_open()) {
Expand All @@ -389,7 +389,7 @@ void SetPortToLockFile(const AutoPort portType, const uint16_t portNumber)

void RemovePortUsage()
{
const fs::path lockFilePath = GetDataDir() / "ports.lock";
const fs::path lockFilePath = GetDataDir(true) / "ports.lock";

// Remove the file. Ignore errors, file might not be present.
std::error_code ec;
Expand Down
Loading