[PATCH v3 4/4] localspl: Unload monitor in DeleteMonitor.
Dmitry Timoshkov
dmitry at baikal.ru
Thu Sep 5 07:31:15 CDT 2019
Some print monitors are very sensitive to loads/unloads being done
in a quick succession like AddMonitor() does, and that even leads to
crashes because the monitor I have here creates a thread on load and
when the thread starts - the monitor dll is already unloaded.
A solution to this is moving the monitor unloading to DeleteMonitor.
Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
dlls/localspl/provider.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/dlls/localspl/provider.c b/dlls/localspl/provider.c
index 0e602ff701..3da71525d1 100644
--- a/dlls/localspl/provider.c
+++ b/dlls/localspl/provider.c
@@ -1560,8 +1560,6 @@ static BOOL WINAPI fpAddMonitor(LPWSTR pName, DWORD Level, LPBYTE pMonitors)
if ((pm = monitor_load(mi2w->pName, mi2w->pDLLName)) == NULL)
res = FALSE;
- monitor_unload(pm);
-
RegCloseKey(hentry);
if (!res)
@@ -1862,6 +1860,7 @@ static BOOL WINAPI fpConfigurePort(LPWSTR pName, HWND hWnd, LPWSTR pPortName)
static BOOL WINAPI fpDeleteMonitor(LPWSTR pName, LPWSTR pEnvironment, LPWSTR pMonitorName)
{
+ monitor_t *pm;
HKEY hroot = NULL;
LONG lres;
@@ -1882,6 +1881,18 @@ static BOOL WINAPI fpDeleteMonitor(LPWSTR pName, LPWSTR pEnvironment, LPWSTR pMo
return FALSE;
}
+ /* Unload the monitor if it's loaded */
+ EnterCriticalSection(&monitor_handles_cs);
+ LIST_FOR_EACH_ENTRY(pm, &monitor_handles, monitor_t, entry)
+ {
+ if (pm->name && !lstrcmpW(pMonitorName, pm->name))
+ {
+ monitor_unload(pm);
+ break;
+ }
+ }
+ LeaveCriticalSection(&monitor_handles_cs);
+
if(RegCreateKeyW(HKEY_LOCAL_MACHINE, monitorsW, &hroot) != ERROR_SUCCESS) {
ERR("unable to create key %s\n", debugstr_w(monitorsW));
return FALSE;
--
2.20.1
More information about the wine-devel
mailing list