From 9f8071ce8f3ba254a3cac6c1cee65706c91ab6d9 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Fri, 31 Dec 2021 20:03:50 -0800 Subject: [PATCH] RootFS: Stop trying to retry rootfs after five times In most cases this will be fixed on the first retry, but give it a chance at five. Otherwise you have a chance to infinite loop. --- Source/Common/RootFSSetup.cpp | 9 +++++++-- Source/Common/RootFSSetup.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/Common/RootFSSetup.cpp b/Source/Common/RootFSSetup.cpp index 1329aa06e6..03b1e9799a 100644 --- a/Source/Common/RootFSSetup.cpp +++ b/Source/Common/RootFSSetup.cpp @@ -358,18 +358,23 @@ ErrorResult SetupSquashFS(char **const envp) { return ErrorResult::ERROR_SUCCESS; } -bool Setup(char **const envp) { +bool Setup(char **const envp, uint32_t TryCount) { // We need to setup the rootfs here // If the configuration is set to use a folder then there is nothing to do // If it is setup to use a squashfs then we need to do something more complex + if (TryCount > 5) { + // Fail if we have retried too many times + return false; + } + // Nothing to do auto Result = SetupSquashFS(envp); if (Result == ErrorResult::ERROR_FAIL) { return false; } else if (Result == ErrorResult::ERROR_TRYAGAIN) { - return Setup(envp); + return Setup(envp, TryCount + 1); } // ERROR_SUCCESS diff --git a/Source/Common/RootFSSetup.h b/Source/Common/RootFSSetup.h index 93276f605b..84c100b0cf 100644 --- a/Source/Common/RootFSSetup.h +++ b/Source/Common/RootFSSetup.h @@ -12,6 +12,6 @@ namespace FEX::RootFS { std::string GetRootFSSocketFile(std::string const &MountPath); // Checks if the rootfs lock exists bool CheckLockExists(std::string const &LockPath, std::string *MountPath = nullptr); - bool Setup(char **const envp); + bool Setup(char **const envp, uint32_t TryCount = 0); void Shutdown(); }