fs: fix retry bug in OpenContentStorageFileSystem

This commit is contained in:
Michael Scire 2020-07-20 13:18:32 -07:00
parent 762db93f4a
commit 9482fafabd
3 changed files with 9 additions and 8 deletions

View file

@ -37,8 +37,7 @@ namespace ams::fssystem::buffers {
} }
R_TRY(on_failure()); R_TRY(on_failure());
/* TODO: os::SleepThread */ os::SleepThread(impl::RetryWait);
svc::SleepThread(impl::RetryWait.GetNanoSeconds());
continue; continue;
} }

View file

@ -61,21 +61,24 @@ namespace ams::fs {
/* It can take some time for the system partition to be ready (if it's on the SD card). */ /* It can take some time for the system partition to be ready (if it's on the SD card). */
/* Thus, we will retry up to 10 times, waiting one second each time. */ /* Thus, we will retry up to 10 times, waiting one second each time. */
constexpr size_t MaxRetries = 10; constexpr size_t MaxRetries = 10;
constexpr u64 RetryInterval = 1'000'000'000ul; constexpr auto RetryInterval = TimeSpan::FromSeconds(1);
/* Mount the content storage, use libnx bindings. */ /* Mount the content storage, use libnx bindings. */
::FsFileSystem fs; ::FsFileSystem fs;
for (size_t i = 0; i < MaxRetries; i++) { for (size_t i = 0; i < MaxRetries; i++) {
/* Try to open the filesystem. */
R_TRY_CATCH(fsOpenContentStorageFileSystem(std::addressof(fs), static_cast<::FsContentStorageId>(id))) { R_TRY_CATCH(fsOpenContentStorageFileSystem(std::addressof(fs), static_cast<::FsContentStorageId>(id))) {
R_CATCH(fs::ResultSystemPartitionNotReady) { R_CATCH(fs::ResultSystemPartitionNotReady) {
if (i < MaxRetries - 1) { if (i < MaxRetries - 1) {
/* TODO: os::SleepThread */ os::SleepThread(RetryInterval);
svcSleepThread(RetryInterval);
} else { } else {
return fs::ResultSystemPartitionNotReady(); return fs::ResultSystemPartitionNotReady();
} }
} }
} R_END_TRY_CATCH; } R_END_TRY_CATCH;
/* The filesystem was opened successfully. */
break;
} }
/* Allocate a new filesystem wrapper. */ /* Allocate a new filesystem wrapper. */

View file

@ -145,8 +145,7 @@ namespace ams::fssystem {
break; break;
} else { } else {
/* Sleep. */ /* Sleep. */
/* TODO: os::SleepThread() */ os::SleepThread(RetryWait);
svc::SleepThread(RetryWait.GetNanoSeconds());
g_retry_count++; g_retry_count++;
} }
} }