[ros-diffs] [ion] 24415: - Fix pushlock calls that were passing the pushlock directly, isntead of a pointer to it. - Half-plement CmpFlushEntireRegistry. - Fix implementation of CmpAllocateDelayItem.

ion at svn.reactos.org ion at svn.reactos.org
Fri Oct 6 00:59:59 CEST 2006


Author: ion
Date: Fri Oct  6 02:59:58 2006
New Revision: 24415

URL: http://svn.reactos.org/svn/reactos?rev=24415&view=rev
Log:
- Fix pushlock calls that were passing the pushlock directly, isntead of a pointer to it.
- Half-plement CmpFlushEntireRegistry.
- Fix implementation of CmpAllocateDelayItem.

Modified:
    branches/alex-cm-branch/reactos/ntoskrnl/cm/cm.h
    branches/alex-cm-branch/reactos/ntoskrnl/cm/cm_x.h
    branches/alex-cm-branch/reactos/ntoskrnl/cm/cmapi.c
    branches/alex-cm-branch/reactos/ntoskrnl/cm/cmkcbncb.c
    branches/alex-cm-branch/reactos/ntoskrnl/cm/cmutil.c

Modified: branches/alex-cm-branch/reactos/ntoskrnl/cm/cm.h
URL: http://svn.reactos.org/svn/reactos/branches/alex-cm-branch/reactos/ntoskrnl/cm/cm.h?rev=24415&r1=24414&r2=24415&view=diff
==============================================================================
--- branches/alex-cm-branch/reactos/ntoskrnl/cm/cm.h (original)
+++ branches/alex-cm-branch/reactos/ntoskrnl/cm/cm.h Fri Oct  6 02:59:58 2006
@@ -1,11 +1,11 @@
 /*
-* PROJECT:         ReactOS Kernel
-* LICENSE:         GPL - See COPYING in the top level directory
-* FILE:            ntoskrnl/cm/cm.h
-* PURPOSE:         Internal header for the Configuration Manager
-* PROGRAMMERS:     Alex Ionescu (alex.ionescu at reactos.org)
-*/
-
+ * PROJECT:         ReactOS Kernel
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * FILE:            ntoskrnl/cm/cm.h
+ * PURPOSE:         Internal header for the Configuration Manager
+ * PROGRAMMERS:     Alex Ionescu (alex.ionescu at reactos.org)
+ */
+#define _CM_
 #include "cmlib.h"
 
 //
@@ -611,11 +611,21 @@
 );
 
 //
+// Flush Routines
+//
+BOOLEAN
+NTAPI
+CmpFlushEntireRegistry(
+    IN BOOLEAN ForceFlush
+);
+
+//
 // Global variables accessible from all of Cm
 //
 extern BOOLEAN CmpSpecialBootCondition;
 extern BOOLEAN CmpFlushOnLockRelease;
-
+extern EX_PUSH_LOCK CmpHiveListHeadLock;
+extern LIST_ENTRY CmpHiveListHead;
 
 //
 // Inlined functions

Modified: branches/alex-cm-branch/reactos/ntoskrnl/cm/cm_x.h
URL: http://svn.reactos.org/svn/reactos/branches/alex-cm-branch/reactos/ntoskrnl/cm/cm_x.h?rev=24415&r1=24414&r2=24415&view=diff
==============================================================================
--- branches/alex-cm-branch/reactos/ntoskrnl/cm/cm_x.h (original)
+++ branches/alex-cm-branch/reactos/ntoskrnl/cm/cm_x.h Fri Oct  6 02:59:58 2006
@@ -64,7 +64,7 @@
 //
 #define CmpAcquireKcbLockExclusive(k)                               \
 {                                                                   \
-    ExAcquirePushLockExclusive(GET_HASH_ENTRY(CmpCacheTable,        \
+    ExAcquirePushLockExclusive(&GET_HASH_ENTRY(CmpCacheTable,       \
                                               (k)->ConvKey).Lock);  \
     GET_HASH_ENTRY(CmpCacheTable,                                   \
                    (k)->ConvKey).Owner = KeGetCurrentThread();      \
@@ -76,8 +76,8 @@
 #define CmpReleaseKcbLock(k)                                        \
 {                                                                   \
     GET_HASH_ENTRY(CmpCacheTable, (k)->ConvKey).Owner = NULL;       \
-    ExReleasePushLock(GET_HASH_ENTRY(CmpCacheTable,                 \
-                                     (k)->ConvKey).Lock);           \
+    ExReleasePushLock(&GET_HASH_ENTRY(CmpCacheTable,                \
+                                      (k)->ConvKey).Lock);          \
 }
 
 //
@@ -85,7 +85,7 @@
 //
 #define CmpAcquireNcbLockExclusive(n)                               \
 {                                                                   \
-    ExAcquirePushLockExclusive(GET_HASH_ENTRY(CmpNameCacheTable,    \
+    ExAcquirePushLockExclusive(&GET_HASH_ENTRY(CmpNameCacheTable,   \
                                               (n)->ConvKey).Lock);  \
 }
 
@@ -94,6 +94,6 @@
 //
 #define CmpReleaseNcbLock(k)                                        \
 {                                                                   \
-    ExReleasePushLock(GET_HASH_ENTRY(CmpNameCacheTable,             \
+    ExReleasePushLock(&GET_HASH_ENTRY(CmpNameCacheTable,            \
                                      (k)->ConvKey).Lock);           \
 }

Modified: branches/alex-cm-branch/reactos/ntoskrnl/cm/cmapi.c
URL: http://svn.reactos.org/svn/reactos/branches/alex-cm-branch/reactos/ntoskrnl/cm/cmapi.c?rev=24415&r1=24414&r2=24415&view=diff
==============================================================================
--- branches/alex-cm-branch/reactos/ntoskrnl/cm/cmapi.c (original)
+++ branches/alex-cm-branch/reactos/ntoskrnl/cm/cmapi.c Fri Oct  6 02:59:58 2006
@@ -12,4 +12,34 @@
 #define NDEBUG
 #include <debug.h>
 
+/* GLOBALS *******************************************************************/
+
+BOOLEAN CmpNoWrite;
+BOOLEAN CmpForceForceFlush;
+
 /* FUNCTIONS *****************************************************************/
+
+BOOLEAN
+NTAPI
+CmpFlushEntireRegistry(IN BOOLEAN ForceFlush)
+{
+    BOOLEAN Flushed = TRUE;
+
+    /* Make sure that the registry isn't read-only now */
+    if (CmpNoWrite) return TRUE;
+
+    /* Otherwise, acquire the hive list lock and disable force flush */
+    CmpForceForceFlush = FALSE;
+    ExAcquirePushLockShared(&CmpHiveListHeadLock);
+
+    /* Check if the hive list isn't empty */
+    if (!IsListEmpty(&CmpHiveListHead))
+    {
+        /* FIXME: TODO */
+        ASSERT(FALSE);
+    }
+
+    /* Release the lock and return the flush state */
+    ExReleasePushLock(&CmpHiveListHeadLock);
+    return Flushed;
+}

Modified: branches/alex-cm-branch/reactos/ntoskrnl/cm/cmkcbncb.c
URL: http://svn.reactos.org/svn/reactos/branches/alex-cm-branch/reactos/ntoskrnl/cm/cmkcbncb.c?rev=24415&r1=24414&r2=24415&view=diff
==============================================================================
--- branches/alex-cm-branch/reactos/ntoskrnl/cm/cmkcbncb.c (original)
+++ branches/alex-cm-branch/reactos/ntoskrnl/cm/cmkcbncb.c Fri Oct  6 02:59:58 2006
@@ -211,8 +211,8 @@
 {
     /* Convert the lock */
     ASSERT(CmpIsKcbLockedExclusive(Kcb) == FALSE);
-    if (ExConvertPushLockSharedToExclusive(GET_HASH_ENTRY(CmpCacheTable,
-                                                          Kcb->ConvKey).Lock))
+    if (ExConvertPushLockSharedToExclusive(&GET_HASH_ENTRY(CmpCacheTable,
+                                                           Kcb->ConvKey).Lock))
     {
         /* Set the lock owner */
         GET_HASH_ENTRY(CmpCacheTable, Kcb->ConvKey).Owner = KeGetCurrentThread();

Modified: branches/alex-cm-branch/reactos/ntoskrnl/cm/cmutil.c
URL: http://svn.reactos.org/svn/reactos/branches/alex-cm-branch/reactos/ntoskrnl/cm/cmutil.c?rev=24415&r1=24414&r2=24415&view=diff
==============================================================================
--- branches/alex-cm-branch/reactos/ntoskrnl/cm/cmutil.c (original)
+++ branches/alex-cm-branch/reactos/ntoskrnl/cm/cmutil.c Fri Oct  6 02:59:58 2006
@@ -50,7 +50,6 @@
     return ExIsResourceAcquiredExclusiveLite(&CmpRegistryLock);
 }
 
-// FIXME: THIS FUNCTION IS PARTIALLY FUCKED
 PVOID
 NTAPI
 CmpAllocateDelayItem(VOID)
@@ -63,45 +62,63 @@
 
     /* Lock the allocation buckets */
     KeAcquireGuardedMutex(&CmpDelayAllocBucketLock);
-    if (TRUE)
+    while (TRUE)
     {
-        /* Allocate an allocation page */
-        AllocPage = ExAllocatePoolWithTag(PagedPool, PAGE_SIZE, TAG_CM);
-        if (AllocPage)
+        /* Get the current entry in the list */
+        NextEntry = CmpFreeDelayItemsListHead.Flink;
+
+        /* Check if we need to allocate an entry */
+        if (((NextEntry) && (CmpFreeDelayItemsListHead.Blink) &&
+             IsListEmpty(&CmpFreeDelayItemsListHead)) ||
+            (!(NextEntry) && !(CmpFreeDelayItemsListHead.Blink)))
         {
-            /* Set default entries */
-            AllocPage->FreeCount = CM_DELAYS_PER_PAGE;
+            /* Allocate an allocation page */
+            AllocPage = ExAllocatePoolWithTag(PagedPool, PAGE_SIZE, TAG_CM);
+            if (AllocPage)
+            {
+                /* Set default entries */
+                AllocPage->FreeCount = CM_DELAYS_PER_PAGE;
 
-            /* Loop each entry */
-            for (i = 0; i < CM_DELAYS_PER_PAGE; i++)
+                /* Loop each entry */
+                for (i = 0; i < CM_DELAYS_PER_PAGE; i++)
+                {
+                    /* Get this entry and link it */
+                    Entry = (PCM_DELAYED_CLOSE_ENTRY)(&AllocPage[i]);
+                    InsertHeadList(&Entry->DelayedLRUList,
+                                   &CmpFreeDelayItemsListHead);
+
+                    /* Clear the KCB pointer */
+                    Entry->KeyControlBlock = NULL;
+                }
+            }
+            else
             {
-                /* Get this entry and link it */
-                Entry = (PCM_DELAYED_CLOSE_ENTRY)(&AllocPage[i]);
-                InsertHeadList(&Entry->DelayedLRUList,
-                               &CmpFreeDelayItemsListHead);
+                /* Release the lock */
+                KeReleaseGuardedMutex(&CmpDelayAllocBucketLock);
+                return NULL;
             }
         }
+    }
 
-        /* Get the entry and the alloc page */
-        Entry = CONTAINING_RECORD(NextEntry,
-                                  CM_DELAYED_CLOSE_ENTRY,
-                                  DelayedLRUList);
-        AllocPage = (PCM_ALLOC_PAGE)((ULONG_PTR)Entry & 0xFFFFF000);
+    /* Set the next item in the list */
+    CmpFreeDelayItemsListHead.Flink = NextEntry->Flink;
+    NextEntry->Flink->Blink = &CmpFreeDelayItemsListHead;
+    NextEntry->Blink = NULL;
 
-        /* Decrease free entries */
-        ASSERT(AllocPage->FreeCount != 0);
-        AllocPage->FreeCount--;
+    /* Get the entry and the alloc page */
+    Entry = CONTAINING_RECORD(NextEntry,
+                              CM_DELAYED_CLOSE_ENTRY,
+                              DelayedLRUList);
+    AllocPage = (PCM_ALLOC_PAGE)((ULONG_PTR)Entry & 0xFFFFF000);
 
-        /* Release the lock */
-        KeReleaseGuardedMutex(&CmpDelayAllocBucketLock);
-        return Entry;
-    }
+    /* Decrease free entries */
+    ASSERT(AllocPage->FreeCount != 0);
+    AllocPage->FreeCount--;
 
     /* Release the lock */
     KeReleaseGuardedMutex(&CmpDelayAllocBucketLock);
     return Entry;
 }
-
 
 VOID
 NTAPI




More information about the Ros-diffs mailing list