[PATCH v4 3/3] localspl: Unload monitor in DeleteMonitor.
Dmitry Timoshkov
dmitry at baikal.ru
Thu Sep 5 23:01:05 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 | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/dlls/localspl/provider.c b/dlls/localspl/provider.c
index 54bd959673..def3215824 100644
--- a/dlls/localspl/provider.c
+++ b/dlls/localspl/provider.c
@@ -1560,10 +1560,7 @@ static BOOL WINAPI fpAddMonitor(LPWSTR pName, DWORD Level, LPBYTE pMonitors)
res = FALSE;
}
else
- {
- monitor_unload(pm);
SetLastError(ERROR_SUCCESS); /* Monitor installer depends on this */
- }
}
RegCloseKey(hentry);
@@ -1857,6 +1854,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;
@@ -1877,6 +1875,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