reduce usb install exit latency by waiting on a cancel uevent, rather than relying on a timeout.

This commit is contained in:
ITotalJustice
2025-05-03 17:17:53 +01:00
parent 30cf4826f8
commit 7072647611
4 changed files with 39 additions and 7 deletions

View File

@@ -10,8 +10,8 @@
namespace sphaira::ui::menu::usb {
namespace {
constexpr u64 CONNECTION_TIMEOUT = 1e+9 * 1; // 1 second
constexpr u64 TRANSFER_TIMEOUT = 1e+9 * 5; // 5 seconds
constexpr u64 CONNECTION_TIMEOUT = UINT64_MAX;
constexpr u64 TRANSFER_TIMEOUT = UINT64_MAX;
void thread_func(void* user) {
auto app = static_cast<Menu*>(user);
@@ -76,6 +76,7 @@ Menu::Menu() : MenuBase{"USB"_i18n} {
}
mutexInit(&m_mutex);
if (m_state != State::Failed) {
threadCreate(&m_thread, thread_func, this, nullptr, 1024*32, 0x2C, 1);
threadStart(&m_thread);
@@ -85,6 +86,7 @@ Menu::Menu() : MenuBase{"USB"_i18n} {
Menu::~Menu() {
// signal for thread to exit and wait.
m_stop_source.request_stop();
m_usb_source->SignalCancel();
threadWaitForExit(&m_thread);
threadClose(&m_thread);
@@ -117,6 +119,8 @@ void Menu::Update(Controller* controller, TouchInfo* touch) {
const auto rc = yati::InstallFromSource(pbox, m_usb_source, file_name);
if (R_FAILED(rc)) {
m_usb_source->SignalCancel();
log_write("exiting usb install\n");
return false;
}