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.
This commit is contained in:
Nekotekina 2020-03-23 22:49:14 +03:00
parent 3d78694590
commit 19e20d9c19
2 changed files with 9 additions and 4 deletions

View file

@ -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)

View file

@ -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)
{