mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[APPWIZ] Add locking in access of download_binding (#5463)
The pointer variable download_binding is used in multiple threads. I thought it needs locking before accessing. CORE-15786
This commit is contained in:
parent
52bc5f7c5d
commit
f85b8fb564
1 changed files with 13 additions and 0 deletions
|
@ -59,6 +59,7 @@ static const addon_info_t addons_info[] = {
|
||||||
static const addon_info_t *addon;
|
static const addon_info_t *addon;
|
||||||
|
|
||||||
static HWND install_dialog = NULL;
|
static HWND install_dialog = NULL;
|
||||||
|
static CRITICAL_SECTION csLock;
|
||||||
static IBinding *download_binding = NULL;
|
static IBinding *download_binding = NULL;
|
||||||
|
|
||||||
static WCHAR GeckoUrl[] = L"https://svn.reactos.org/amine/wine_gecko-2.40-x86.msi";
|
static WCHAR GeckoUrl[] = L"https://svn.reactos.org/amine/wine_gecko-2.40-x86.msi";
|
||||||
|
@ -260,8 +261,12 @@ static HRESULT WINAPI InstallCallback_OnStartBinding(IBindStatusCallback *iface,
|
||||||
DWORD dwReserved, IBinding *pib)
|
DWORD dwReserved, IBinding *pib)
|
||||||
{
|
{
|
||||||
set_status(IDS_DOWNLOADING);
|
set_status(IDS_DOWNLOADING);
|
||||||
|
|
||||||
IBinding_AddRef(pib);
|
IBinding_AddRef(pib);
|
||||||
|
|
||||||
|
EnterCriticalSection(&csLock);
|
||||||
download_binding = pib;
|
download_binding = pib;
|
||||||
|
LeaveCriticalSection(&csLock);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -294,10 +299,12 @@ static HRESULT WINAPI InstallCallback_OnProgress(IBindStatusCallback *iface, ULO
|
||||||
static HRESULT WINAPI InstallCallback_OnStopBinding(IBindStatusCallback *iface,
|
static HRESULT WINAPI InstallCallback_OnStopBinding(IBindStatusCallback *iface,
|
||||||
HRESULT hresult, LPCWSTR szError)
|
HRESULT hresult, LPCWSTR szError)
|
||||||
{
|
{
|
||||||
|
EnterCriticalSection(&csLock);
|
||||||
if(download_binding) {
|
if(download_binding) {
|
||||||
IBinding_Release(download_binding);
|
IBinding_Release(download_binding);
|
||||||
download_binding = NULL;
|
download_binding = NULL;
|
||||||
}
|
}
|
||||||
|
LeaveCriticalSection(&csLock);
|
||||||
|
|
||||||
if(FAILED(hresult)) {
|
if(FAILED(hresult)) {
|
||||||
if(hresult == E_ABORT)
|
if(hresult == E_ABORT)
|
||||||
|
@ -401,12 +408,14 @@ static INT_PTR CALLBACK installer_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch(wParam) {
|
switch(wParam) {
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
|
EnterCriticalSection(&csLock);
|
||||||
if(download_binding) {
|
if(download_binding) {
|
||||||
IBinding_Abort(download_binding);
|
IBinding_Abort(download_binding);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
EndDialog(hwnd, 0);
|
EndDialog(hwnd, 0);
|
||||||
}
|
}
|
||||||
|
LeaveCriticalSection(&csLock);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
case ID_DWL_INSTALL:
|
case ID_DWL_INSTALL:
|
||||||
|
@ -436,6 +445,8 @@ BOOL install_addon(addon_t addon_type, HWND hwnd_parent)
|
||||||
|
|
||||||
addon = addons_info + addon_type;
|
addon = addons_info + addon_type;
|
||||||
|
|
||||||
|
InitializeCriticalSection(&csLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try to find addon .msi file in following order:
|
* Try to find addon .msi file in following order:
|
||||||
* - directory stored in $dir_config_key value of HKCU/Wine/Software/$config_key key
|
* - directory stored in $dir_config_key value of HKCU/Wine/Software/$config_key key
|
||||||
|
@ -444,5 +455,7 @@ BOOL install_addon(addon_t addon_type, HWND hwnd_parent)
|
||||||
if (install_from_registered_dir() == INSTALL_NEXT)
|
if (install_from_registered_dir() == INSTALL_NEXT)
|
||||||
DialogBoxW(hApplet, addon->dialog_template, hwnd_parent, installer_proc);
|
DialogBoxW(hApplet, addon->dialog_template, hwnd_parent, installer_proc);
|
||||||
|
|
||||||
|
DeleteCriticalSection(&csLock);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue