Huw Davies : winspool: Only perform printer initialisation once per session .

Alexandre Julliard julliard at winehq.org
Fri May 18 14:09:15 CDT 2012


Module: wine
Branch: master
Commit: 7b0cda21406d0d3e3231e220b9d30c0cf813da3c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7b0cda21406d0d3e3231e220b9d30c0cf813da3c

Author: Huw Davies <huw at codeweavers.com>
Date:   Fri May 18 13:43:56 2012 +0100

winspool: Only perform printer initialisation once per session.

---

 dlls/winspool.drv/info.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index 614cfa2..afba8a1 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -1076,12 +1076,31 @@ static void old_printer_check( BOOL delete_phase )
     HeapFree(GetProcessHeap(), 0, pi);
 }
 
+static const WCHAR winspool_mutex_name[] = {'_','_','W','I','N','E','_','W','I','N','S','P','O','O','L','_',
+                                            'M','U','T','E','X','_','_','\0'};
+
 void WINSPOOL_LoadSystemPrinters(void)
 {
     HKEY                hkey, hkeyPrinters;
     DWORD               needed, num, i;
     WCHAR               PrinterName[256];
     BOOL                done = FALSE;
+    HANDLE              mutex;
+
+    /* FIXME: The init code should be moved to spoolsv.exe */
+    mutex = CreateMutexW( NULL, TRUE, winspool_mutex_name );
+    if (!mutex)
+    {
+        ERR( "Failed to create mutex\n" );
+        return;
+    }
+    if (GetLastError() == ERROR_ALREADY_EXISTS)
+    {
+        WaitForSingleObject( mutex, INFINITE );
+        ReleaseMutex( mutex );
+        TRACE( "Init already done\n" );
+        return;
+    }
 
     /* This ensures that all printer entries have a valid Name value.  If causes
        problems later if they don't.  If one is found to be missed we create one
@@ -1114,6 +1133,7 @@ void WINSPOOL_LoadSystemPrinters(void)
 
     old_printer_check( TRUE );
 
+    ReleaseMutex( mutex );
     return;
 }
 




More information about the wine-cvs mailing list