[RAPPS] Protect database update with a mutex (#7006)

This commit is contained in:
Whindmar Saksit 2025-01-11 19:52:07 +01:00 committed by GitHub
parent e5a6b0f8e5
commit 3ff8adc553
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 45 additions and 2 deletions

View file

@ -338,6 +338,7 @@ ParseCmdAndExecute(LPWSTR lpCmdLine, BOOL bIsFirstLaunch, int nCmdShow)
BOOL bAppwizMode = (argc > 1 && MatchCmdOption(argv[1], CMD_KEY_APPWIZ));
if (!bAppwizMode)
{
CUpdateDatabaseMutex lock;
if (SettingsInfo.bUpdateAtStart || bIsFirstLaunch)
db.RemoveCached();
@ -350,7 +351,7 @@ ParseCmdAndExecute(LPWSTR lpCmdLine, BOOL bIsFirstLaunch, int nCmdShow)
{
// Check whether the RAPPS MainWindow is already launched in another process
CStringW szWindowText(MAKEINTRESOURCEW(bAppwizMode ? IDS_APPWIZ_TITLE : IDS_APPTITLE));
LPCWSTR pszMutex = bAppwizMode ? L"RAPPWIZ" : szWindowClass;
LPCWSTR pszMutex = bAppwizMode ? L"RAPPWIZ" : MAINWINDOWMUTEX;
HANDLE hMutex = CreateMutexW(NULL, FALSE, pszMutex);
if ((!hMutex) || (GetLastError() == ERROR_ALREADY_EXISTS))