Dmitry Timoshkov : localspl: Unload monitor in DeleteMonitor.

Alexandre Julliard julliard at winehq.org
Fri Sep 6 16:05:42 CDT 2019


Module: wine
Branch: master
Commit: db4d01e191484729743839f9e2640cad5fef57fe
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=db4d01e191484729743839f9e2640cad5fef57fe

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Fri Sep  6 12:01:05 2019 +0800

localspl: Unload monitor in DeleteMonitor.

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>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 54bd959..def3215 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;




More information about the wine-cvs mailing list