[PATCH] spoolss: Properly initialize the backends

Detlef Riekenberg wine.dev at web.de
Sun Feb 15 17:13:22 CST 2009


---
 dlls/spoolss/router.c |   33 +++++++++++++++++++++++++++------
 1 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/dlls/spoolss/router.c b/dlls/spoolss/router.c
index c3b9bb8..8cf02ff 100644
--- a/dlls/spoolss/router.c
+++ b/dlls/spoolss/router.c
@@ -211,6 +211,8 @@ static backend_t * backend_load(LPWSTR dllname, LPWSTR name, LPWSTR regroot)
     DWORD id;
     DWORD res;
 
+    TRACE("(%s, %s, %s)\n", debugstr_w(dllname), debugstr_w(name), debugstr_w(regroot));
+
     EnterCriticalSection(&backend_cs);
     id = used_backends;
 
@@ -263,13 +265,22 @@ static backend_t * backend_load(LPWSTR dllname, LPWSTR name, LPWSTR regroot)
  */
 BOOL backend_load_all(void)
 {
+    static BOOL failed = FALSE;
     backend_t * pb;
 
-    pb = backend_load(localsplW, NULL, NULL);
+    EnterCriticalSection(&backend_cs);
+
+    /* if we failed before, dont try again */
+    if (!failed && (used_backends == 0)) {
+        pb = backend_load(localsplW, NULL, NULL);
 
-    /* ToDo: parse the registry and load all other backends */
+        /* ToDo: parse the registry and load all other backends */
 
-    return (pb != NULL);
+        failed = (used_backends == 0);
+    }
+    LeaveCriticalSection(&backend_cs);
+    TRACE("-> %d\n", !failed);
+    return (!failed);
 }
 
 /******************************************************************************
@@ -284,10 +295,20 @@ BOOL backend_load_all(void)
  */
 static backend_t * backend_first(LPWSTR name)
 {
-    /* test for the local system first */
-    if(!name || !name[0]) return backend[0];
 
-    FIXME("server %s not supported\n", debugstr_w(name));
+    EnterCriticalSection(&backend_cs);
+    /* Load all backends, when not done yet */
+    if (used_backends || backend_load_all()) {
+
+        /* test for the local system first */
+        if (!name || !name[0]) {
+            LeaveCriticalSection(&backend_cs);
+            return backend[0];
+        }
+    }
+
+    FIXME("server %s not supported in %d backends\n", debugstr_w(name), used_backends);
+    LeaveCriticalSection(&backend_cs);
     return NULL;
 }
 
-- 
1.5.4.3


--=-z+aoCRdZjlcXF6kml4i7--




More information about the wine-patches mailing list