- Implement IoFreeErrorLogEntry().
[reactos.git] / reactos / ntoskrnl / io / errlog.c
index 49c9452..5c11fcc 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errlog.c,v 1.17 2004/06/23 21:42:50 ion Exp $
+/* $Id: errlog.c,v 1.20 2004/09/28 12:51:14 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
 
 /* INCLUDES *****************************************************************/
 
-#include <ddk/ntddk.h>
-
-#include <internal/port.h>
-
+#include <ntoskrnl.h>
 #define NDEBUG
 #include <internal/debug.h>
 
@@ -121,11 +118,7 @@ IopRestartLogWorker (VOID)
   KeInitializeTimer (&WorkerDpc->Timer);
 
   /* Restart after 30 seconds */
-#if defined(__GNUC__)
-  Timeout.QuadPart = -300000000LL;
-#else
-  Timeout.QuadPart = -300000000;
-#endif
+  Timeout.QuadPart = (LONGLONG)-300000000;
   KeSetTimer (&WorkerDpc->Timer,
              Timeout,
              &WorkerDpc->Dpc);
@@ -184,7 +177,6 @@ IopLogWorker (PVOID Parameter)
   /* Release the work item */
   ExFreePool (Parameter);
 
-
   /* Connect to the error log port */
   if (IopLogPortConnected == FALSE)
     {
@@ -322,7 +314,7 @@ IopLogWorker (PVOID Parameter)
       KeAcquireSpinLock (&IopAllocationLock,
                         &Irql);
 
-      IopTotalLogSize -= LogEntry->PacketSize;
+      IopTotalLogSize -= (LogEntry->PacketSize - sizeof(ERROR_LOG_ENTRY));
       ExFreePool (LogEntry);
 
       KeReleaseSpinLock (&IopAllocationLock,
@@ -346,7 +338,7 @@ IoAllocateErrorLogEntry (IN PVOID IoObject,
   ULONG LogEntrySize;
   KIRQL Irql;
 
-  DPRINT("IoAllocateErrorLogEntry() called\n");
+  DPRINT("IoAllocateErrorLogEntry() called\n");
 
   if (IoObject == NULL)
     return NULL;
@@ -382,18 +374,34 @@ IoAllocateErrorLogEntry (IN PVOID IoObject,
   return (PVOID)((ULONG_PTR)LogEntry + sizeof(ERROR_LOG_ENTRY));
 }
 
+
 /*
- * @unimplemented
+ * @implemented
  */
-STDCALL
-VOID
-IoFreeErrorLogEntry(
-    PVOID ElEntry
-    )
+VOID STDCALL
+IoFreeErrorLogEntry(IN PVOID ElEntry)
 {
-       UNIMPLEMENTED;
+  PERROR_LOG_ENTRY LogEntry;
+  KIRQL Irql;
+
+  DPRINT("IoFreeErrorLogEntry() called\n");
+
+  if (ElEntry == NULL)
+    return;
+
+  LogEntry = (PERROR_LOG_ENTRY)((ULONG_PTR)ElEntry - sizeof(ERROR_LOG_ENTRY));
+
+  KeAcquireSpinLock(&IopAllocationLock,
+                   &Irql);
+
+  IopTotalLogSize -= (LogEntry->PacketSize - sizeof(ERROR_LOG_ENTRY));
+  ExFreePool(LogEntry);
+
+  KeReleaseSpinLock(&IopAllocationLock,
+                   Irql);
 }
 
+
 /*
  * @implemented
  */
@@ -404,7 +412,7 @@ IoWriteErrorLogEntry (IN PVOID ElEntry)
   PERROR_LOG_ENTRY LogEntry;
   KIRQL Irql;
 
-  DPRINT ("IoWriteErrorLogEntry() called\n");
+  DPRINT("IoWriteErrorLogEntry() called\n");
 
   LogEntry = (PERROR_LOG_ENTRY)((ULONG_PTR)ElEntry - sizeof(ERROR_LOG_ENTRY));
 
@@ -437,7 +445,7 @@ IoWriteErrorLogEntry (IN PVOID ElEntry)
   KeReleaseSpinLock (&IopLogListLock,
                     Irql);
 
-  DPRINT ("IoWriteErrorLogEntry() done\n");
+  DPRINT("IoWriteErrorLogEntry() done\n");
 }
 
 /* EOF */