[Wine-patches] [eter-2.1 2/2] winspool.drv: Move loading of libcups out of the init code protected by mutex. (eterbug #8054)

Dmitry Timoshkov dtimoshkov на etersoft.ru
Вт Апр 2 10:20:20 MSK 2013


(cherry picked from commit 142c2982dc3ce33a09004a284a5b99328945a654)
---
 dlls/winspool.drv/info.c | 41 +++++++++++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 14 deletions(-)

diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index dd84598..e8ae259 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -878,6 +878,28 @@ static cups_ptype_t get_cups_printer_type( const cups_dest_t *dest )
     return ret;
 }
 
+static void load_cups(void)
+{
+    cupshandle = wine_dlopen( SONAME_LIBCUPS, RTLD_NOW, NULL, 0 );
+    if (!cupshandle) return;
+
+    TRACE("%p: %s loaded\n", cupshandle, SONAME_LIBCUPS);
+
+#define DO_FUNC(x) \
+    p##x = wine_dlsym( cupshandle, #x, NULL, 0 ); \
+    if (!p##x) \
+    { \
+        ERR("failed to load symbol %s\n", #x); \
+        cupshandle = NULL; \
+        return; \
+    }
+    CUPS_FUNCS;
+#undef DO_FUNC
+#define DO_FUNC(x) p##x = wine_dlsym( cupshandle, #x, NULL, 0 )
+    CUPS_OPT_FUNCS;
+#undef DO_FUNC
+}
+
 static BOOL CUPS_LoadPrinters(void)
 {
     int	                  i, nrofdests;
@@ -886,26 +908,13 @@ static BOOL CUPS_LoadPrinters(void)
     PRINTER_INFO_2W       pi2;
     WCHAR *port, *ppd_dir = NULL, *ppd;
     HKEY hkeyPrinter, hkeyPrinters;
-    char    loaderror[256];
     const char *Location, *Description;
     WCHAR   nameW[MAX_PATH];
     WCHAR LocW[MAX_PATH], DesW[MAX_PATH];
     HANDLE  added_printer;
     cups_ptype_t printer_type;
 
-    cupshandle = wine_dlopen(SONAME_LIBCUPS, RTLD_NOW, loaderror, sizeof(loaderror));
-    if (!cupshandle) {
-        TRACE("%s\n", loaderror);
-        return FALSE;
-    }
-    TRACE("%p: %s loaded\n", cupshandle, SONAME_LIBCUPS);
-
-#define DO_FUNC(x) p##x = wine_dlsym( cupshandle, #x, NULL, 0 ); if (!p##x) return FALSE
-    CUPS_FUNCS;
-#undef DO_FUNC
-#define DO_FUNC(x) p##x = wine_dlsym( cupshandle, #x, NULL, 0 )
-    CUPS_OPT_FUNCS;
-#undef DO_FUNC
+    if (!cupshandle) return FALSE;
 
     if(RegCreateKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters) !=
        ERROR_SUCCESS) {
@@ -1606,6 +1615,10 @@ void WINSPOOL_LoadSystemPrinters(void)
     WCHAR               PrinterName[256];
     BOOL                done = FALSE;
 
+#ifdef SONAME_LIBCUPS
+    load_cups();
+#endif
+
     /* FIXME: The init code should be moved to spoolsv.exe */
     init_mutex = CreateMutexW( NULL, TRUE, winspool_mutex_name );
     if (!init_mutex)
-- 
1.8.2



Подробная информация о списке рассылки Wine-patches