mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Corrected a memory leak in the read cleanup code
svn path=/trunk/; revision=116
This commit is contained in:
parent
4bc75819a3
commit
6eaf6180fd
7 changed files with 31 additions and 12 deletions
|
@ -37,6 +37,7 @@ VOID IoReadWriteCompletion(PDEVICE_OBJECT DeviceObject,
|
||||||
DPRINT("Copying buffered io back to user\n");
|
DPRINT("Copying buffered io back to user\n");
|
||||||
memcpy(Irp->UserBuffer,Irp->AssociatedIrp.SystemBuffer,
|
memcpy(Irp->UserBuffer,Irp->AssociatedIrp.SystemBuffer,
|
||||||
IoStack->Parameters.Read.Length);
|
IoStack->Parameters.Read.Length);
|
||||||
|
ExFreePool(Irp->AssociatedIrp.SystemBuffer);
|
||||||
}
|
}
|
||||||
if (DeviceObject->Flags & DO_DIRECT_IO)
|
if (DeviceObject->Flags & DO_DIRECT_IO)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
#include <wstring.h>
|
#include <wstring.h>
|
||||||
|
|
||||||
//#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
/* FUNCTIONS *************************************************************/
|
/* FUNCTIONS *************************************************************/
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
static LIST_ENTRY DpcQueueHead={NULL,NULL};
|
static LIST_ENTRY DpcQueueHead={NULL,NULL};
|
||||||
static KSPIN_LOCK DpcQueueLock={0,};
|
static KSPIN_LOCK DpcQueueLock={0,};
|
||||||
|
ULONG DpcQueueSize = 0;
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@ void KeDrainDpcQueue(void)
|
||||||
current->Lock=FALSE;
|
current->Lock=FALSE;
|
||||||
KeRaiseIrql(HIGH_LEVEL,&oldlvl);
|
KeRaiseIrql(HIGH_LEVEL,&oldlvl);
|
||||||
current_entry = RemoveHeadList(&DpcQueueHead);
|
current_entry = RemoveHeadList(&DpcQueueHead);
|
||||||
|
DpcQueueSize--;
|
||||||
KeLowerIrql(oldlvl);
|
KeLowerIrql(oldlvl);
|
||||||
current = CONTAINING_RECORD(¤t_entry,KDPC,DpcListEntry);
|
current = CONTAINING_RECORD(¤t_entry,KDPC,DpcListEntry);
|
||||||
}
|
}
|
||||||
|
@ -88,6 +90,7 @@ BOOLEAN KeRemoveQueueDpc(PKDPC Dpc)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
RemoveEntryList(&Dpc->DpcListEntry);
|
RemoveEntryList(&Dpc->DpcListEntry);
|
||||||
|
DpcQueueSize--;
|
||||||
Dpc->Lock=0;
|
Dpc->Lock=0;
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
@ -117,6 +120,7 @@ BOOLEAN KeInsertQueueDpc(PKDPC dpc, PVOID SystemArgument1,
|
||||||
}
|
}
|
||||||
KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
|
KeAcquireSpinLockAtDpcLevel(&DpcQueueLock);
|
||||||
InsertHeadList(&DpcQueueHead,&dpc->DpcListEntry);
|
InsertHeadList(&DpcQueueHead,&dpc->DpcListEntry);
|
||||||
|
DpcQueueSize++;
|
||||||
KeReleaseSpinLockFromDpcLevel(&DpcQueueLock);
|
KeReleaseSpinLockFromDpcLevel(&DpcQueueLock);
|
||||||
dpc->Lock=(PULONG)1;
|
dpc->Lock=(PULONG)1;
|
||||||
DPRINT("DpcQueueHead.Flink %x\n",DpcQueueHead.Flink);
|
DPRINT("DpcQueueHead.Flink %x\n",DpcQueueHead.Flink);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -413,6 +414,8 @@ static void HandleExpiredTimer(PKTIMER current)
|
||||||
{
|
{
|
||||||
if (current->dpc!=NULL)
|
if (current->dpc!=NULL)
|
||||||
{
|
{
|
||||||
|
DPRINT("current->dpc->DeferredRoutine %x\n",
|
||||||
|
current->dpc->DeferredRoutine);
|
||||||
current->dpc->DeferredRoutine(current->dpc,
|
current->dpc->DeferredRoutine(current->dpc,
|
||||||
current->dpc->DeferredContext,
|
current->dpc->DeferredContext,
|
||||||
current->dpc->SystemArgument1,
|
current->dpc->SystemArgument1,
|
||||||
|
@ -457,13 +460,15 @@ void KeExpireTimers(void)
|
||||||
KeReleaseSpinLock(&timer_list_lock,oldlvl);
|
KeReleaseSpinLock(&timer_list_lock,oldlvl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern unsigned int nr_used_blocks;
|
||||||
|
|
||||||
VOID KiTimerInterrupt(VOID)
|
VOID KiTimerInterrupt(VOID)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Handles a timer interrupt
|
* FUNCTION: Handles a timer interrupt
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
char str[16];
|
char str[36];
|
||||||
char* vidmem=(char *)physical_to_linear(0xb8000 + 160 - 16);
|
char* vidmem=(char *)physical_to_linear(0xb8000 + 160 - 36);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -476,8 +481,8 @@ VOID KiTimerInterrupt(VOID)
|
||||||
* Display the tick count in the top left of the screen as a debugging
|
* Display the tick count in the top left of the screen as a debugging
|
||||||
* aid
|
* aid
|
||||||
*/
|
*/
|
||||||
sprintf(str,"%.8u",ticks);
|
sprintf(str,"%.8u %.8u",nr_used_blocks,ticks);
|
||||||
for (i=0;i<8;i++)
|
for (i=0;i<17;i++)
|
||||||
{
|
{
|
||||||
*vidmem=str[i];
|
*vidmem=str[i];
|
||||||
vidmem++;
|
vidmem++;
|
||||||
|
|
|
@ -58,7 +58,7 @@ static unsigned int kernel_pool_base = 0;
|
||||||
static block_hdr* free_list_head = NULL;
|
static block_hdr* free_list_head = NULL;
|
||||||
static block_hdr* used_list_head = NULL;
|
static block_hdr* used_list_head = NULL;
|
||||||
static unsigned int nr_free_blocks = 0;
|
static unsigned int nr_free_blocks = 0;
|
||||||
static unsigned int nr_used_blocks = 0;
|
unsigned int nr_used_blocks = 0;
|
||||||
|
|
||||||
#define ALLOC_MAP_SIZE (NONPAGED_POOL_SIZE / PAGESIZE)
|
#define ALLOC_MAP_SIZE (NONPAGED_POOL_SIZE / PAGESIZE)
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ ZwAllocateVirtualMemory(
|
||||||
ULONG Type;
|
ULONG Type;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DbgPrint("ZwAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
|
DPRINT("ZwAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
|
||||||
"ZeroBits %d, RegionSize %d, AllocationType %x, Protect %x)\n",
|
"ZeroBits %d, RegionSize %d, AllocationType %x, Protect %x)\n",
|
||||||
ProcessHandle,*BaseAddress,ZeroBits,*RegionSize,AllocationType,
|
ProcessHandle,*BaseAddress,ZeroBits,*RegionSize,AllocationType,
|
||||||
Protect);
|
Protect);
|
||||||
|
@ -323,7 +323,7 @@ ZwAllocateVirtualMemory(
|
||||||
NULL);
|
NULL);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (Status != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
DbgPrint("ZwAllocateVirtualMemory() = %x\n",Status);
|
DPRINT("ZwAllocateVirtualMemory() = %x\n",Status);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ ZwAllocateVirtualMemory(
|
||||||
{
|
{
|
||||||
MemoryArea->Type = Type;
|
MemoryArea->Type = Type;
|
||||||
MemoryArea->Attributes =Protect;
|
MemoryArea->Attributes =Protect;
|
||||||
DbgPrint("*BaseAddress %x\n",*BaseAddress);
|
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ ZwAllocateVirtualMemory(
|
||||||
*RegionSize,
|
*RegionSize,
|
||||||
Type,
|
Type,
|
||||||
Protect);
|
Protect);
|
||||||
DbgPrint("*BaseAddress %x\n",*BaseAddress);
|
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,11 +375,11 @@ ZwAllocateVirtualMemory(
|
||||||
|
|
||||||
if (Status != STATUS_SUCCESS)
|
if (Status != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
DbgPrint("ZwAllocateVirtualMemory() = %x\n",Status);
|
DPRINT("ZwAllocateVirtualMemory() = %x\n",Status);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
DbgPrint("*BaseAddress %x\n",*BaseAddress);
|
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,23 @@
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
HANDLE IdleThreadHandle = NULL;
|
HANDLE IdleThreadHandle = NULL;
|
||||||
|
extern ULONG DpcQueueSize;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
static VOID PsIdleThreadMain(PVOID Context)
|
static VOID PsIdleThreadMain(PVOID Context)
|
||||||
{
|
{
|
||||||
|
KIRQL oldlvl;
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
// DbgPrint("Idling.... ");
|
// DbgPrint("Idling.... ");
|
||||||
|
if (DpcQueueSize > 0)
|
||||||
|
{
|
||||||
|
KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
|
||||||
|
KeDrainDpcQueue();
|
||||||
|
KeLowerIrql(oldlvl);
|
||||||
|
}
|
||||||
ZwYieldExecution();
|
ZwYieldExecution();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue