- Re-use WorkItem
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Sat, 4 Apr 2009 16:04:25 +0000 (16:04 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Sat, 4 Apr 2009 16:04:25 +0000 (16:04 +0000)
- Fixes leaking a workitem for each pin creation request

svn path=/trunk/; revision=40360

reactos/drivers/wdm/audio/backpln/portcls/adapter.c
reactos/drivers/wdm/audio/backpln/portcls/port_topology.c
reactos/drivers/wdm/audio/backpln/portcls/private.h

index e686dc1..8ea63f3 100644 (file)
@@ -10,9 +10,6 @@
  */
 
 #include "private.h"
-#include <devguid.h>
-#include <initguid.h>
-#include <ksmedia.h>
 
 /*
     This is called from DriverEntry so that PortCls can take care of some
@@ -152,6 +149,9 @@ PcAddAdapterDevice(
     /* clear initializing flag */
     fdo->Flags &= ~ DO_DEVICE_INITIALIZING;
 
+    /* allocate work item */
+    portcls_ext->WorkItem = IoAllocateWorkItem(fdo);
+
     /* allocate the device header */
     status = KsAllocateDeviceHeader(&portcls_ext->KsDeviceHeader, MaxObjects, portcls_ext->CreateItems);
     /* did we succeed */
index 2598d05..d83913d 100644 (file)
@@ -500,7 +500,6 @@ PcCreateItemDispatch(
     IIrpTarget *Filter;
     PKSOBJECT_CREATE_ITEM CreateItem;
     PPIN_WORKER_CONTEXT Context;
-    PIO_WORKITEM WorkItem;
 
     DPRINT("PcCreateItemDispatch called DeviceObject %p\n", DeviceObject);
 
@@ -599,20 +598,11 @@ PcCreateItemDispatch(
             Context->Filter = Filter;
             Context->Irp = Irp;
 
-            WorkItem = IoAllocateWorkItem(DeviceObject);
-            if (!WorkItem)
-            {
-                Irp->IoStatus.Information = 0;
-                Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
-                FreeItem(Context, TAG_PORTCLASS);
-                IoCompleteRequest(Irp, IO_NO_INCREMENT);
-                return STATUS_INSUFFICIENT_RESOURCES;
-            }
             DPRINT("Queueing IRP %p Irql %u\n", Irp, KeGetCurrentIrql());
             Irp->IoStatus.Information = 0;
             Irp->IoStatus.Status = STATUS_PENDING;
             IoMarkIrpPending(Irp);
-            IoQueueWorkItem(WorkItem, CreatePinWorkerRoutine, DelayedWorkQueue, (PVOID)Context);
+            IoQueueWorkItem(DeviceExt->WorkItem, CreatePinWorkerRoutine, DelayedWorkQueue, (PVOID)Context);
 
             return STATUS_PENDING;
         }
index 57806e8..65b1edf 100644 (file)
@@ -156,7 +156,7 @@ typedef struct
     ULONG MaxSubDevices;
     KSOBJECT_CREATE_ITEM * CreateItems;
 
-
+    PIO_WORKITEM WorkItem;
     IResourceList* resources;
     LIST_ENTRY SubDeviceList;
     LIST_ENTRY PhysicalConnectionList;