mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-18 01:46:47 +00:00
fs: fix retry bug in OpenContentStorageFileSystem
This commit is contained in:
parent
762db93f4a
commit
9482fafabd
3 changed files with 9 additions and 8 deletions
|
@ -37,8 +37,7 @@ namespace ams::fssystem::buffers {
|
|||
}
|
||||
R_TRY(on_failure());
|
||||
|
||||
/* TODO: os::SleepThread */
|
||||
svc::SleepThread(impl::RetryWait.GetNanoSeconds());
|
||||
os::SleepThread(impl::RetryWait);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -60,22 +60,25 @@ namespace ams::fs {
|
|||
|
||||
/* 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. */
|
||||
constexpr size_t MaxRetries = 10;
|
||||
constexpr u64 RetryInterval = 1'000'000'000ul;
|
||||
constexpr size_t MaxRetries = 10;
|
||||
constexpr auto RetryInterval = TimeSpan::FromSeconds(1);
|
||||
|
||||
/* Mount the content storage, use libnx bindings. */
|
||||
::FsFileSystem fs;
|
||||
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_CATCH(fs::ResultSystemPartitionNotReady) {
|
||||
if (i < MaxRetries - 1) {
|
||||
/* TODO: os::SleepThread */
|
||||
svcSleepThread(RetryInterval);
|
||||
os::SleepThread(RetryInterval);
|
||||
} else {
|
||||
return fs::ResultSystemPartitionNotReady();
|
||||
}
|
||||
}
|
||||
} R_END_TRY_CATCH;
|
||||
|
||||
/* The filesystem was opened successfully. */
|
||||
break;
|
||||
}
|
||||
|
||||
/* Allocate a new filesystem wrapper. */
|
||||
|
|
|
@ -145,8 +145,7 @@ namespace ams::fssystem {
|
|||
break;
|
||||
} else {
|
||||
/* Sleep. */
|
||||
/* TODO: os::SleepThread() */
|
||||
svc::SleepThread(RetryWait.GetNanoSeconds());
|
||||
os::SleepThread(RetryWait);
|
||||
g_retry_count++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue