From 19e20d9c199d77da08455dd678a9299f07eac84b Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Mon, 23 Mar 2020 22:49:14 +0300 Subject: [PATCH] Auto-Updater: increase lock file waiting timeout in the case of updating Normal case: timeout reduced from 3s to 2s. Updating case: increased timeout to 10s. --- rpcs3/main.cpp | 9 +++++++-- rpcs3/rpcs3qt/update_manager.cpp | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/rpcs3/main.cpp b/rpcs3/main.cpp index 17cfd3fb54..fb5147c72e 100644 --- a/rpcs3/main.cpp +++ b/rpcs3/main.cpp @@ -172,6 +172,7 @@ const char* arg_styles = "styles"; const char* arg_style = "style"; const char* arg_stylesheet = "stylesheet"; const char* arg_error = "error"; +const char* arg_updating = "updating"; int find_arg(std::string arg, int& argc, char* argv[]) { @@ -295,9 +296,13 @@ int main(int argc, char** argv) fs::file instance_lock; - for (u32 num = 0; num < 100 && !instance_lock.open(lock_name, fs::rewrite + fs::lock); num++) + // True if an argument --updating found + const bool is_updating = find_arg(arg_updating, argc, argv) != 0; + + // Keep trying to lock the file for ~2s normally, and for ~10s in the case of --updating + for (u32 num = 0; num < (is_updating ? 500u : 100u) && !instance_lock.open(lock_name, fs::rewrite + fs::lock); num++) { - std::this_thread::sleep_for(30ms); + std::this_thread::sleep_for(20ms); } if (!instance_lock) diff --git a/rpcs3/rpcs3qt/update_manager.cpp b/rpcs3/rpcs3qt/update_manager.cpp index a898aac320..80188284c9 100644 --- a/rpcs3/rpcs3qt/update_manager.cpp +++ b/rpcs3/rpcs3qt/update_manager.cpp @@ -596,9 +596,9 @@ bool update_manager::handle_rpcs3() QMessageBox::information(m_parent, tr("Auto-updater"), tr("Update successful!")); #ifdef _WIN32 - const int ret = _wexecl(orig_path, orig_path, nullptr); + const int ret = _wexecl(orig_path, orig_path, L"--updating", nullptr); #else - const int ret = execl(replace_path.c_str(), replace_path.c_str(), nullptr); + const int ret = execl(replace_path.c_str(), replace_path.c_str(), "--updating", nullptr); #endif if (ret == -1) {