GDI dead lock fix
eric pouech
eric.pouech at wanadoo.fr
Tue Aug 14 15:37:56 CDT 2001
in some cases, Windows Media player was dead locking
this was done between the GDI and the PEB lock (the peb lock is used
to maintain the list of GDI driver)
given the natural order to set the locks, I replaced the use of the peb
lock with a private cs to do the job
A+
--
---------------
Eric Pouech (http://perso.wanadoo.fr/eric.pouech/)
"The future will be better tomorrow", Vice President Dan Quayle
-------------- next part --------------
Name: gdi_cs
ChangeLog: replaced peblock by private CS to avoid dead locks
GenDate: 2001/08/14 20:27:36 UTC
ModifiedFiles: dlls/gdi/driver.c
AddedFiles:
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/dlls/gdi/driver.c,v
retrieving revision 1.4
diff -u -u -r1.4 driver.c
--- dlls/gdi/driver.c 2001/07/31 17:25:47 1.4
+++ dlls/gdi/driver.c 2001/08/14 08:18:43
@@ -7,7 +7,6 @@
#include <string.h>
#include "winbase.h"
#include "winreg.h"
-#include "ntddk.h"
#include "gdi.h"
#include "debugtools.h"
@@ -26,6 +25,7 @@
static struct graphics_driver *first_driver;
static struct graphics_driver *display_driver;
+static CRITICAL_SECTION csDriver = CRITICAL_SECTION_INIT;
/**********************************************************************
* create_driver
@@ -203,18 +203,17 @@
const DC_FUNCTIONS *DRIVER_load_driver( LPCSTR name )
{
HMODULE module;
- struct graphics_driver *driver;
+ struct graphics_driver *driver = NULL;
- RtlAcquirePebLock();
+ EnterCriticalSection( &csDriver );
/* display driver is a special case */
if (!strcasecmp( name, "display" ))
{
driver = load_display_driver();
- RtlReleasePebLock();
- return &driver->funcs;
+ goto done;
}
-
+
if ((module = GetModuleHandleA( name )))
{
for (driver = first_driver; driver; driver = driver->next)
@@ -222,28 +221,26 @@
if (driver->module == module)
{
driver->count++;
- RtlReleasePebLock();
- return &driver->funcs;
+ break;
}
}
}
- if (!(module = LoadLibraryA( name )))
+ if (!driver && (module = LoadLibraryA( name )))
{
- RtlReleasePebLock();
- return NULL;
+ if (!(driver = create_driver( module )))
+ {
+ FreeLibrary( module );
+ }
+ else
+ {
+ TRACE( "loaded driver %p for %s\n", driver, name );
+ }
}
- if (!(driver = create_driver( module )))
- {
- FreeLibrary( module );
- RtlReleasePebLock();
- return NULL;
- }
-
- TRACE( "loaded driver %p for %s\n", driver, name );
- RtlReleasePebLock();
- return &driver->funcs;
+ done:
+ LeaveCriticalSection( &csDriver );
+ return driver ? &driver->funcs : NULL;
}
@@ -256,12 +253,12 @@
{
struct graphics_driver *driver;
- RtlAcquirePebLock();
+ EnterCriticalSection( &csDriver );
for (driver = first_driver; driver; driver = driver->next)
if (&driver->funcs == funcs) break;
if (!driver) ERR( "driver not found, trouble ahead\n" );
- driver->count++;
- RtlReleasePebLock();
+ else driver->count++;
+ LeaveCriticalSection( &csDriver );
return funcs;
}
@@ -275,7 +272,7 @@
{
struct graphics_driver *driver;
- RtlAcquirePebLock();
+ EnterCriticalSection( &csDriver );
for (driver = first_driver; driver; driver = driver->next)
if (&driver->funcs == funcs) break;
@@ -292,7 +289,7 @@
FreeLibrary( driver->module );
HeapFree( GetProcessHeap(), 0, driver );
done:
- RtlReleasePebLock();
+ LeaveCriticalSection( &csDriver );
}
More information about the wine-patches
mailing list