ReactOS  0.4.14-dev-115-g4576127
cmdelay.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for cmdelay.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

 _Function_class_ (KDEFERRED_ROUTINE)
 
 _Function_class_ (WORKER_THREAD_ROUTINE)
 
INIT_FUNCTION VOID NTAPI CmpInitializeDelayedCloseTable (VOID)
 
INIT_FUNCTION VOID NTAPI CmpInitDelayDerefKCBEngine (VOID)
 
VOID NTAPI CmpDelayDerefKeyControlBlock (IN PCM_KEY_CONTROL_BLOCK Kcb)
 
VOID NTAPI CmpArmDelayedCloseTimer (VOID)
 
VOID NTAPI CmpAddToDelayedClose (IN PCM_KEY_CONTROL_BLOCK Kcb, IN BOOLEAN LockHeldExclusively)
 
VOID NTAPI CmpRemoveFromDelayedClose (IN PCM_KEY_CONTROL_BLOCK Kcb)
 

Variables

WORK_QUEUE_ITEM CmpDelayDerefKCBWorkItem
 
ULONG CmpDelayedCloseSize = 2048
 
ULONG CmpDelayedCloseElements
 
KGUARDED_MUTEX CmpDelayedCloseTableLock
 
BOOLEAN CmpDelayCloseWorkItemActive
 
WORK_QUEUE_ITEM CmpDelayCloseWorkItem
 
LIST_ENTRY CmpDelayedLRUListHead
 
ULONG CmpDelayCloseIntervalInSeconds = 5
 
KDPC CmpDelayCloseDpc
 
KTIMER CmpDelayCloseTimer
 
KGUARDED_MUTEX CmpDelayDerefKCBLock
 
BOOLEAN CmpDelayDerefKCBWorkItemActive
 
LIST_ENTRY CmpDelayDerefKCBListHead
 
ULONG CmpDelayDerefKCBIntervalInSeconds = 5
 
KDPC CmpDelayDerefKCBDpc
 
KTIMER CmpDelayDerefKCBTimer
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file cmdelay.c.

Function Documentation

◆ _Function_class_() [1/2]

_Function_class_ ( KDEFERRED_ROUTINE  )

Definition at line 38 of file cmdelay.c.

45 {
46  /* Sanity check */
48 
49  /* Queue the work item */
51 }
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
Definition: work.c:717
WORK_QUEUE_ITEM CmpDelayCloseWorkItem
Definition: cmdelay.c:23
BOOLEAN CmpDelayCloseWorkItemActive
Definition: cmdelay.c:22
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

◆ _Function_class_() [2/2]

_Function_class_ ( WORKER_THREAD_ROUTINE  )

Definition at line 53 of file cmdelay.c.

57 {
58  PCM_DELAYED_CLOSE_ENTRY ListEntry;
59  ULONG i, ConvKey;
60  PAGED_CODE();
61 
62  /* Sanity check */
64 
65  /* Lock the registry */
67 
68  /* Acquire the delayed close table lock */
70 
71  /* Iterate */
72  for (i = 0; i < (CmpDelayedCloseSize >> 2); i++)
73  {
74  /* Break out of the loop if there is nothing to process */
76 
77  /* Sanity check */
79 
80  /* Get the entry */
83  DelayedLRUList);
84 
85  /* Save the ConvKey value of the KCB */
86  ConvKey = ListEntry->KeyControlBlock->ConvKey;
87 
88  /* Release the delayed close table lock */
90 
91  /* Acquire the KCB lock */
93 
94  /* Reacquire the delayed close table lock */
96 
97  /* Get the entry */
100  DelayedLRUList);
101 
102  /* Is the entry we have still the first one? */
104  {
105  /* No, someone already inserted an entry there */
106  CmpReleaseKcbLockByKey(ConvKey);
107  break;
108  }
109 
110  /* Is it a different entry? */
111  if (ConvKey != ListEntry->KeyControlBlock->ConvKey)
112  {
113  /* Release the delayed close table lock */
115 
116  /* Release the KCB lock */
117  CmpReleaseKcbLockByKey(ConvKey);
118 
119  /* Reacquire the delayed close table lock */
121 
122  /* Iterate again */
123  continue;
124  }
125 
126  /* Remove it from the end of the list */
127  ListEntry =
129 
130  /* Get the containing entry */
131  ListEntry = CONTAINING_RECORD(ListEntry,
133  DelayedLRUList);
134 
135  /* Process the entry */
136  if ((ListEntry->KeyControlBlock->RefCount) ||
137  (ListEntry->KeyControlBlock->DelayedCloseIndex))
138  {
139  /* Add it to the beginning of the list */
141 
142  /* Release the delayed close table lock */
144  }
145  else
146  {
147  /* Release the delayed close table lock */
149 
150  /* Zero out the DelayCloseEntry pointer */
151  ListEntry->KeyControlBlock->DelayCloseEntry = NULL;
152 
153  /* Cleanup the KCB cache */
155 
156  /* Free the delay item */
157  CmpFreeDelayItem(ListEntry);
158 
159  /* Decrement delayed close elements count */
161  }
162 
163  /* Release the KCB lock */
164  CmpReleaseKcbLockByKey(ConvKey);
165 
166  /* Reacquire the delayed close table lock */
168  }
169 
171  {
172  /* We're not active anymore */
174  }
175  else
176  {
177  /* We didn't process all things, so reschedule for the next time */
179  }
180 
181  /* Release the delayed close table lock */
183 
184  /* Unlock the registry */
186 }
KGUARDED_MUTEX CmpDelayedCloseTableLock
Definition: cmdelay.c:21
ULONG CmpDelayedCloseSize
Definition: cmdelay.c:19
ULONG CmpDelayedCloseElements
Definition: cmdelay.c:20
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
FORCEINLINE PLIST_ENTRY RemoveTailList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:154
PCM_KEY_CONTROL_BLOCK KeyControlBlock
Definition: cm.h:360
FORCEINLINE VOID CmpAcquireKcbLockExclusiveByKey(IN ULONG ConvKey)
Definition: cm_x.h:112
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
VOID NTAPI CmpCleanUpKcbCacheWithLock(IN PCM_KEY_CONTROL_BLOCK Kcb, IN BOOLEAN LockHeldExclusively)
Definition: cmkcbncb.c:476
#define PAGED_CODE()
Definition: video.h:57
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN CmpDelayCloseWorkItemActive
Definition: cmdelay.c:22
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
FORCEINLINE VOID CmpReleaseKcbLockByKey(ULONG ConvKey)
Definition: cm_x.h:179
VOID NTAPI CmpUnlockRegistry(VOID)
Definition: cmsysini.c:1993
LIST_ENTRY DelayedLRUList
Definition: cm.h:359
Definition: cm.h:357
ULONG DelayedCloseIndex
Definition: cm.h:267
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define InterlockedDecrement
Definition: armddk.h:52
LIST_ENTRY CmpDelayedLRUListHead
Definition: cmdelay.c:24
struct _CM_DELAYED_CLOSE_ENTRY * PCM_DELAYED_CLOSE_ENTRY
VOID NTAPI CmpFreeDelayItem(PVOID Entry)
Definition: cmalloc.c:266
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
unsigned int ULONG
Definition: retypes.h:1
ULONG RefCount
Definition: cm.h:261
PVOID DelayCloseEntry
Definition: cm.h:297
VOID NTAPI CmpArmDelayedCloseTimer(VOID)
Definition: cmdelay.c:335
signed int * PLONG
Definition: retypes.h:5
VOID NTAPI CmpLockRegistry(VOID)
Definition: cmsysini.c:1907

◆ CmpAddToDelayedClose()

VOID NTAPI CmpAddToDelayedClose ( IN PCM_KEY_CONTROL_BLOCK  Kcb,
IN BOOLEAN  LockHeldExclusively 
)

Definition at line 350 of file cmdelay.c.

352 {
353  ULONG i;
354  ULONG OldRefCount, NewRefCount;
356  PAGED_CODE();
357 
358  /* Sanity check */
359  CMP_ASSERT_KCB_LOCK(Kcb);
360 
361  /* Make sure it's valid */
362  if (Kcb->DelayedCloseIndex != CmpDelayedCloseSize) ASSERT(FALSE);
363 
364  /* Sanity checks */
365  ASSERT(Kcb->RefCount == 0);
366  ASSERT(IsListEmpty(&Kcb->KeyBodyListHead) == TRUE);
367  for (i = 0; i < 4; i++) ASSERT(Kcb->KeyBodyArray[i] == NULL);
368 
369  /* Allocate a delay item */
371  if (!Entry)
372  {
373  /* Cleanup immediately */
374  CmpCleanUpKcbCacheWithLock(Kcb, LockHeldExclusively);
375  return;
376  }
377 
378  /* Sanity check */
379  if (Kcb->InDelayClose) ASSERT(FALSE);
380 
381  /* Get the previous reference count */
382  OldRefCount = *(PLONG)&Kcb->InDelayClose;
383  ASSERT(OldRefCount == 0);
384 
385  /* Write the new one */
386  NewRefCount = 1;
387  if (InterlockedCompareExchange((PLONG)&Kcb->InDelayClose,
388  NewRefCount,
389  OldRefCount) != OldRefCount)
390  {
391  /* Sanity check */
392  ASSERT(FALSE);
393  }
394 
395  /* Reset the delayed close index */
396  Kcb->DelayedCloseIndex = 0;
397 
398  /* Set up the close entry */
399  Kcb->DelayCloseEntry = Entry;
400  Entry->KeyControlBlock = Kcb;
401 
402  /* Increase the number of elements */
404 
405  /* Acquire the delayed close table lock */
407 
408  /* Insert the entry into the list */
409  InsertHeadList(&CmpDelayedLRUListHead, &Entry->DelayedLRUList);
410 
411  /* Check if we need to enable anything */
414  {
415  /* Yes, we have too many elements to close, and no work item */
417  }
418 
419  /* Release the table lock */
421 }
KGUARDED_MUTEX CmpDelayedCloseTableLock
Definition: cmdelay.c:21
ULONG CmpDelayedCloseSize
Definition: cmdelay.c:19
#define TRUE
Definition: types.h:120
struct _Entry Entry
Definition: kefuncs.h:640
ULONG CmpDelayedCloseElements
Definition: cmdelay.c:20
#define CMP_ASSERT_KCB_LOCK(k)
Definition: cm_x.h:245
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
#define InterlockedCompareExchange
Definition: interlocked.h:104
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
VOID NTAPI CmpCleanUpKcbCacheWithLock(IN PCM_KEY_CONTROL_BLOCK Kcb, IN BOOLEAN LockHeldExclusively)
Definition: cmkcbncb.c:476
#define PAGED_CODE()
Definition: video.h:57
PVOID NTAPI CmpAllocateDelayItem(VOID)
Definition: cmalloc.c:196
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN CmpDelayCloseWorkItemActive
Definition: cmdelay.c:22
Definition: cm.h:357
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
LIST_ENTRY CmpDelayedLRUListHead
Definition: cmdelay.c:24
#define InterlockedIncrement
Definition: armddk.h:53
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI CmpArmDelayedCloseTimer(VOID)
Definition: cmdelay.c:335
signed int * PLONG
Definition: retypes.h:5
base of all file and directory entries
Definition: entries.h:82

Referenced by CmpDereferenceKeyControlBlockWithLock().

◆ CmpArmDelayedCloseTimer()

VOID NTAPI CmpArmDelayedCloseTimer ( VOID  )

Definition at line 335 of file cmdelay.c.

336 {
338  PAGED_CODE();
339 
340  /* Set the worker active */
342 
343  /* Setup the interval */
344  Timeout.QuadPart = CmpDelayCloseIntervalInSeconds * -10000000;
346 }
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
#define PAGED_CODE()
Definition: video.h:57
KTIMER CmpDelayCloseTimer
Definition: cmdelay.c:27
KDPC CmpDelayCloseDpc
Definition: cmdelay.c:26
BOOLEAN CmpDelayCloseWorkItemActive
Definition: cmdelay.c:22
static ULONG Timeout
Definition: ping.c:61
ULONG CmpDelayCloseIntervalInSeconds
Definition: cmdelay.c:25

Referenced by _Function_class_(), and CmpAddToDelayedClose().

◆ CmpDelayDerefKeyControlBlock()

VOID NTAPI CmpDelayDerefKeyControlBlock ( IN PCM_KEY_CONTROL_BLOCK  Kcb)

Definition at line 286 of file cmdelay.c.

287 {
288  LONG OldRefCount, NewRefCount;
291  PAGED_CODE();
293  "%s - Dereferencing KCB: %p\n", __FUNCTION__, Kcb);
294 
295  /* Get the previous reference count */
296  OldRefCount = *(PLONG)&Kcb->RefCount;
297  NewRefCount = OldRefCount - 1;
298  if (((NewRefCount & 0xFFFF) > 0) &&
299  (InterlockedCompareExchange((PLONG)&Kcb->RefCount,
300  NewRefCount,
301  OldRefCount) == OldRefCount))
302  {
303  /* KCB still had references, so we're done */
304  return;
305  }
306 
307  /* Allocate a delay item */
309  if (!Entry) return;
310 
311  /* Set the KCB */
312  Entry->Kcb = Kcb;
313 
314  /* Acquire the delayed deref table lock */
316 
317  /* Insert the entry into the list */
319 
320  /* Check if we need to enable anything */
322  {
323  /* Yes, we have no work item, setup the interval */
325  Timeout.QuadPart = CmpDelayDerefKCBIntervalInSeconds * -10000000;
327  }
328 
329  /* Release the table lock */
331 }
#define CMTRACE(x, fmt,...)
Definition: cm.h:36
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
struct _Entry Entry
Definition: kefuncs.h:640
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
#define CM_REFERENCE_DEBUG
Definition: cm.h:22
#define InterlockedCompareExchange
Definition: interlocked.h:104
#define InsertTailList(ListHead, Entry)
#define PAGED_CODE()
Definition: video.h:57
PVOID NTAPI CmpAllocateDelayItem(VOID)
Definition: cmalloc.c:196
long LONG
Definition: pedump.c:60
KGUARDED_MUTEX CmpDelayDerefKCBLock
Definition: cmdelay.c:29
ULONG CmpDelayDerefKCBIntervalInSeconds
Definition: cmdelay.c:32
BOOLEAN CmpDelayDerefKCBWorkItemActive
Definition: cmdelay.c:30
LIST_ENTRY CmpDelayDerefKCBListHead
Definition: cmdelay.c:31
if(!(yy_init))
Definition: macro.lex.yy.c:714
KTIMER CmpDelayDerefKCBTimer
Definition: cmdelay.c:34
static ULONG Timeout
Definition: ping.c:61
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
KDPC CmpDelayDerefKCBDpc
Definition: cmdelay.c:33
#define __FUNCTION__
Definition: types.h:112
signed int * PLONG
Definition: retypes.h:5
base of all file and directory entries
Definition: entries.h:82

Referenced by CmpCleanUpKcbCacheWithLock(), CmpCleanUpKcbValueCache(), and CmpDeleteKeyObject().

◆ CmpInitDelayDerefKCBEngine()

INIT_FUNCTION VOID NTAPI CmpInitDelayDerefKCBEngine ( VOID  )

Definition at line 268 of file cmdelay.c.

269 {
270  /* Initialize lock and list */
273 
274  /* Setup the work item */
276  CmpDelayDerefKCBWorker,
277  NULL);
278 
279  /* Setup the DPC and timer for it */
280  KeInitializeDpc(&CmpDelayDerefKCBDpc, CmpDelayDerefKCBDpcRoutine, NULL);
282 }
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
KGUARDED_MUTEX CmpDelayDerefKCBLock
Definition: cmdelay.c:29
WORK_QUEUE_ITEM CmpDelayDerefKCBWorkItem
Definition: cmdelay.c:17
LIST_ENTRY CmpDelayDerefKCBListHead
Definition: cmdelay.c:31
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
KTIMER CmpDelayDerefKCBTimer
Definition: cmdelay.c:34
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
KDPC CmpDelayDerefKCBDpc
Definition: cmdelay.c:33
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711

Referenced by CmInitSystem1().

◆ CmpInitializeDelayedCloseTable()

INIT_FUNCTION VOID NTAPI CmpInitializeDelayedCloseTable ( VOID  )

Definition at line 191 of file cmdelay.c.

192 {
193 
194  /* Setup the delayed close lock */
196 
197  /* Setup the work item */
198  ExInitializeWorkItem(&CmpDelayCloseWorkItem, CmpDelayCloseWorker, NULL);
199 
200  /* Setup the list head */
202 
203  /* Setup the DPC and its timer */
204  KeInitializeDpc(&CmpDelayCloseDpc, CmpDelayCloseDpcRoutine, NULL);
206 }
KGUARDED_MUTEX CmpDelayedCloseTableLock
Definition: cmdelay.c:21
WORK_QUEUE_ITEM CmpDelayCloseWorkItem
Definition: cmdelay.c:23
KTIMER CmpDelayCloseTimer
Definition: cmdelay.c:27
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
KDPC CmpDelayCloseDpc
Definition: cmdelay.c:26
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
LIST_ENTRY CmpDelayedLRUListHead
Definition: cmdelay.c:24
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711

Referenced by CmpInitializeCache().

◆ CmpRemoveFromDelayedClose()

VOID NTAPI CmpRemoveFromDelayedClose ( IN PCM_KEY_CONTROL_BLOCK  Kcb)

Definition at line 425 of file cmdelay.c.

426 {
428  ULONG NewRefCount, OldRefCount;
429  PAGED_CODE();
430 
431  /* Sanity checks */
432  CMP_ASSERT_KCB_LOCK(Kcb);
433  if (Kcb->DelayedCloseIndex == CmpDelayedCloseSize) ASSERT(FALSE);
434 
435  /* Get the entry and lock the table */
436  Entry = Kcb->DelayCloseEntry;
437  ASSERT(Entry);
439 
440  /* Remove the entry */
441  RemoveEntryList(&Entry->DelayedLRUList);
442 
443  /* Release the lock */
445 
446  /* Free the entry */
448 
449  /* Reduce the number of elements */
451 
452  /* Sanity check */
453  if (!Kcb->InDelayClose) ASSERT(FALSE);
454 
455  /* Get the previous reference count */
456  OldRefCount = *(PLONG)&Kcb->InDelayClose;
457  ASSERT(OldRefCount == 1);
458 
459  /* Write the new one */
460  NewRefCount = 0;
461  if (InterlockedCompareExchange((PLONG)&Kcb->InDelayClose,
462  NewRefCount,
463  OldRefCount) != OldRefCount)
464  {
465  /* Sanity check */
466  ASSERT(FALSE);
467  }
468 
469  /* Remove the link to the entry */
470  Kcb->DelayCloseEntry = NULL;
471 
472  /* Set new delay size and remove the delete flag */
473  Kcb->DelayedCloseIndex = CmpDelayedCloseSize;
474 }
KGUARDED_MUTEX CmpDelayedCloseTableLock
Definition: cmdelay.c:21
ULONG CmpDelayedCloseSize
Definition: cmdelay.c:19
struct _Entry Entry
Definition: kefuncs.h:640
ULONG CmpDelayedCloseElements
Definition: cmdelay.c:20
#define CMP_ASSERT_KCB_LOCK(k)
Definition: cm_x.h:245
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
#define InterlockedCompareExchange
Definition: interlocked.h:104
#define PAGED_CODE()
Definition: video.h:57
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
smooth NULL
Definition: ftsmooth.c:416
Definition: cm.h:357
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define InterlockedDecrement
Definition: armddk.h:52
VOID NTAPI CmpFreeDelayItem(PVOID Entry)
Definition: cmalloc.c:266
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
unsigned int ULONG
Definition: retypes.h:1
signed int * PLONG
Definition: retypes.h:5
base of all file and directory entries
Definition: entries.h:82

Referenced by CmpEnumerateOpenSubKeys(), and CmpReferenceKeyControlBlock().

Variable Documentation

◆ CmpDelayCloseDpc

KDPC CmpDelayCloseDpc

Definition at line 26 of file cmdelay.c.

Referenced by CmpArmDelayedCloseTimer(), and CmpInitializeDelayedCloseTable().

◆ CmpDelayCloseIntervalInSeconds

ULONG CmpDelayCloseIntervalInSeconds = 5

Definition at line 25 of file cmdelay.c.

Referenced by CmpArmDelayedCloseTimer().

◆ CmpDelayCloseTimer

KTIMER CmpDelayCloseTimer

Definition at line 27 of file cmdelay.c.

Referenced by CmpArmDelayedCloseTimer(), and CmpInitializeDelayedCloseTable().

◆ CmpDelayCloseWorkItem

WORK_QUEUE_ITEM CmpDelayCloseWorkItem

Definition at line 23 of file cmdelay.c.

Referenced by _Function_class_(), and CmpInitializeDelayedCloseTable().

◆ CmpDelayCloseWorkItemActive

BOOLEAN CmpDelayCloseWorkItemActive

Definition at line 22 of file cmdelay.c.

Referenced by _Function_class_(), CmpAddToDelayedClose(), and CmpArmDelayedCloseTimer().

◆ CmpDelayDerefKCBDpc

KDPC CmpDelayDerefKCBDpc

Definition at line 33 of file cmdelay.c.

Referenced by CmpDelayDerefKeyControlBlock(), and CmpInitDelayDerefKCBEngine().

◆ CmpDelayDerefKCBIntervalInSeconds

ULONG CmpDelayDerefKCBIntervalInSeconds = 5

Definition at line 32 of file cmdelay.c.

Referenced by CmpDelayDerefKeyControlBlock().

◆ CmpDelayDerefKCBListHead

LIST_ENTRY CmpDelayDerefKCBListHead

Definition at line 31 of file cmdelay.c.

Referenced by CmpDelayDerefKeyControlBlock(), and CmpInitDelayDerefKCBEngine().

◆ CmpDelayDerefKCBLock

KGUARDED_MUTEX CmpDelayDerefKCBLock

Definition at line 29 of file cmdelay.c.

Referenced by CmpDelayDerefKeyControlBlock(), and CmpInitDelayDerefKCBEngine().

◆ CmpDelayDerefKCBTimer

KTIMER CmpDelayDerefKCBTimer

Definition at line 34 of file cmdelay.c.

Referenced by CmpDelayDerefKeyControlBlock(), and CmpInitDelayDerefKCBEngine().

◆ CmpDelayDerefKCBWorkItem

WORK_QUEUE_ITEM CmpDelayDerefKCBWorkItem

Definition at line 17 of file cmdelay.c.

Referenced by CmpInitDelayDerefKCBEngine().

◆ CmpDelayDerefKCBWorkItemActive

BOOLEAN CmpDelayDerefKCBWorkItemActive

Definition at line 30 of file cmdelay.c.

Referenced by CmpDelayDerefKeyControlBlock().

◆ CmpDelayedCloseElements

ULONG CmpDelayedCloseElements

Definition at line 20 of file cmdelay.c.

Referenced by _Function_class_(), CmpAddToDelayedClose(), and CmpRemoveFromDelayedClose().

◆ CmpDelayedCloseSize

◆ CmpDelayedCloseTableLock

KGUARDED_MUTEX CmpDelayedCloseTableLock

◆ CmpDelayedLRUListHead

LIST_ENTRY CmpDelayedLRUListHead