Don't calll GDIOBJ_vDereferenceObject from GDIOBJ_vUnlockObject, instead manually decrement the reference count. This allows us to ASSERT that the former function is never called with an exclusive lock held.

svn path=/trunk/; revision=56458
This commit is contained in:
Timo Kreuzer 2012-05-01 09:29:41 +00:00
parent bb3050e722
commit c99f588f86

View file

@ -476,6 +476,9 @@ GDIOBJ_vDereferenceObject(POBJ pobj)
{ {
ULONG cRefs, ulIndex; ULONG cRefs, ulIndex;
/* Must not be exclusively locked */
ASSERT(pobj->cExclusiveLock == 0);
/* Check if the object has a handle */ /* Check if the object has a handle */
if (GDI_HANDLE_GET_INDEX(pobj->hHmgr)) if (GDI_HANDLE_GET_INDEX(pobj->hHmgr))
{ {
@ -647,11 +650,13 @@ VOID
NTAPI NTAPI
GDIOBJ_vUnlockObject(POBJ pobj) GDIOBJ_vUnlockObject(POBJ pobj)
{ {
ULONG cRefs, ulIndex;
ASSERT(pobj->cExclusiveLock > 0); ASSERT(pobj->cExclusiveLock > 0);
/* Decrease lock count */ /* Decrease lock count */
pobj->cExclusiveLock--; pobj->cExclusiveLock--;
DBG_DECREASE_LOCK_COUNT(PsGetCurrentProcessWin32Process(), pobj->hHmgr); DBG_DECREASE_LOCK_COUNT(PsGetCurrentProcessWin32Process(), pobj->hHmgr);
DBG_LOGEVENT(&pobj->slhLog, EVENT_UNLOCK, 0);
/* Check if this was the last lock */ /* Check if this was the last lock */
if (pobj->cExclusiveLock == 0) if (pobj->cExclusiveLock == 0)
@ -664,9 +669,13 @@ GDIOBJ_vUnlockObject(POBJ pobj)
KeLeaveCriticalRegion(); KeLeaveCriticalRegion();
} }
/* Dereference the object */ /* Calculate the index */
DBG_LOGEVENT(&pobj->slhLog, EVENT_UNLOCK, 0); ulIndex = GDI_HANDLE_GET_INDEX(pobj->hHmgr);
GDIOBJ_vDereferenceObject(pobj);
/* Decrement reference count */
ASSERT((gpaulRefCount[ulIndex] & REF_MASK_COUNT) > 0);
cRefs = InterlockedDecrement((LONG*)&gpaulRefCount[ulIndex]);
ASSERT(cRefs & REF_MASK_VALID);
} }
HGDIOBJ HGDIOBJ