From cb10422980a9b9796fbe79ab3964d4c2701ba983 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Tue, 18 Nov 2003 20:08:30 +0000 Subject: [PATCH] Initialize error log worker. svn path=/trunk/; revision=6690 --- reactos/ntoskrnl/io/errlog.c | 107 ++++++++++++++++++++++++++++++++--- reactos/ntoskrnl/io/iomgr.c | 3 +- 2 files changed, 101 insertions(+), 9 deletions(-) diff --git a/reactos/ntoskrnl/io/errlog.c b/reactos/ntoskrnl/io/errlog.c index 1f02ef65f28..d31514480f0 100644 --- a/reactos/ntoskrnl/io/errlog.c +++ b/reactos/ntoskrnl/io/errlog.c @@ -1,4 +1,4 @@ -/* $Id: errlog.c,v 1.11 2003/08/14 18:30:28 silverblade Exp $ +/* $Id: errlog.c,v 1.12 2003/11/18 20:08:30 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -41,6 +41,7 @@ typedef struct _IO_ERROR_LOG_PACKET typedef struct _ERROR_LOG_ENTRY { + LIST_ENTRY Entry; ULONG EntrySize; } ERROR_LOG_ENTRY, *PERROR_LOG_ENTRY; @@ -50,6 +51,11 @@ typedef struct _ERROR_LOG_ENTRY static KSPIN_LOCK IopAllocationLock; static ULONG IopTotalLogSize; +static KSPIN_LOCK IopLogListLock; +static LIST_ENTRY IopLogListHead; + +static BOOLEAN IopLogWorkerRunning = FALSE; + /* FUNCTIONS *****************************************************************/ @@ -59,10 +65,76 @@ IopInitErrorLog (VOID) IopTotalLogSize = 0; KeInitializeSpinLock (&IopAllocationLock); + KeInitializeSpinLock (&IopLogListLock); + InitializeListHead (&IopLogListHead); + return STATUS_SUCCESS; } +static VOID STDCALL +IopLogWorker (PVOID Parameter) +{ + PERROR_LOG_ENTRY LogEntry; + KIRQL Irql; + + DPRINT1 ("IopLogWorker() called\n"); + + /* Release the work item */ + ExFreePool (Parameter); + + + /* FIXME: Open the error log port */ + + + while (TRUE) + { + /* Remove last entry from the list */ + KeAcquireSpinLock (&IopLogListLock, + &Irql); + + if (!IsListEmpty(&IopLogListHead)) + { + LogEntry = CONTAINING_RECORD (IopLogListHead.Blink, + ERROR_LOG_ENTRY, + Entry); + RemoveEntryList (&LogEntry->Entry); + } + else + { + LogEntry = NULL; + } + + KeReleaseSpinLock (&IopLogListLock, + Irql); + + if (LogEntry == NULL) + { + DPRINT1 ("No message in log list\n"); + break; + } + + + + /* FIXME: Send the error message to the log port */ + + + + /* Release error log entry */ + KeAcquireSpinLock (&IopAllocationLock, + &Irql); + + IopTotalLogSize -= LogEntry->EntrySize; + ExFreePool (LogEntry); + + KeReleaseSpinLock (&IopAllocationLock, + Irql); + } + + DPRINT1 ("IopLogWorker() done\n"); +} + + /* * @implemented */ @@ -111,11 +183,12 @@ IoAllocateErrorLogEntry (IN PVOID IoObject, /* - * @unimplemented + * @implemented */ VOID STDCALL IoWriteErrorLogEntry (IN PVOID ElEntry) { + PWORK_QUEUE_ITEM LogWorkItem; PERROR_LOG_ENTRY LogEntry; KIRQL Irql; @@ -124,18 +197,36 @@ IoWriteErrorLogEntry (IN PVOID ElEntry) LogEntry = (PERROR_LOG_ENTRY)((ULONG_PTR)ElEntry - sizeof(ERROR_LOG_ENTRY)); - /* FIXME: Write log entry to the error log port or keep it in a list */ + /* FIXME: Get logging time */ - /* Release error log entry */ - KeAcquireSpinLock (&IopAllocationLock, + KeAcquireSpinLock (&IopLogListLock, &Irql); - IopTotalLogSize -= LogEntry->EntrySize; - ExFreePool (LogEntry); + InsertHeadList (&IopLogListHead, + &LogEntry->Entry); - KeReleaseSpinLock (&IopAllocationLock, + if (IopLogWorkerRunning == FALSE) + { + LogWorkItem = ExAllocatePool (NonPagedPool, + sizeof(WORK_QUEUE_ITEM)); + if (LogWorkItem != NULL) + { + ExInitializeWorkItem (LogWorkItem, + IopLogWorker, + LogWorkItem); + + ExQueueWorkItem (LogWorkItem, + DelayedWorkQueue); + + IopLogWorkerRunning = TRUE; + } + } + + KeReleaseSpinLock (&IopLogListLock, Irql); + + DPRINT1 ("IoWriteErrorLogEntry() done\n"); } /* EOF */ diff --git a/reactos/ntoskrnl/io/iomgr.c b/reactos/ntoskrnl/io/iomgr.c index 94cc7449fb8..cfb8d8e4b57 100644 --- a/reactos/ntoskrnl/io/iomgr.c +++ b/reactos/ntoskrnl/io/iomgr.c @@ -1,4 +1,4 @@ -/* $Id: iomgr.c,v 1.43 2003/11/17 02:12:51 hyperion Exp $ +/* $Id: iomgr.c,v 1.44 2003/11/18 20:08:30 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -343,6 +343,7 @@ IoInit (VOID) IoInitFileSystemImplementation(); IoInitVpbImplementation(); IoInitShutdownNotification(); + IopInitErrorLog(); /* * Create link from '\DosDevices' to '\??' directory