mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-23 04:41:12 +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());
|
R_TRY(on_failure());
|
||||||
|
|
||||||
/* TODO: os::SleepThread */
|
os::SleepThread(impl::RetryWait);
|
||||||
svc::SleepThread(impl::RetryWait.GetNanoSeconds());
|
|
||||||
|
|
||||||
continue;
|
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). */
|
/* 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. */
|
||||||
|
|
|
@ -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++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue