[bus,aoe] Make threads responsible for bus FDO removal
authorShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Wed, 5 Jan 2011 21:59:14 +0000 (16:59 -0500)
committerShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Wed, 5 Jan 2011 21:59:14 +0000 (16:59 -0500)
The bus library probably shouldn't assume control of FDO
association and destruction at removal-time.

src/aoe/driver.c
src/winvblock/bus.c
src/winvblock/libbus/pnp.c

index 60a58e1..d459d85 100644 (file)
@@ -1274,6 +1274,13 @@ static VOID STDCALL AoeThread_(IN PVOID StartContext) {
         if (AoeStop_) {
             DBG("Stopping...\n");
             WvlBusCancelWorkItems(&AoeBusMain);
+            /* Detach from any lower DEVICE_OBJECT */
+            if (AoeBusMain.LowerDeviceObject)
+              IoDetachDevice(AoeBusMain.LowerDeviceObject);
+            /* Delete. */
+            IoDeleteDevice(AoeBusMain.Fdo);
+            /* Disassociate. */
+            AoeBusMain.Fdo = NULL;
             PsTerminateSystemThread(STATUS_SUCCESS);
           }
         WvlBusProcessWorkItems(&AoeBusMain);
index 779f111..569c9c5 100644 (file)
@@ -116,6 +116,13 @@ static VOID STDCALL WvBusThread(IN OUT WVL_SP_THREAD_ITEM item) {
         (WvBusThread_.State == WvlThreadStateStopping)
       );
     WvlBusCancelWorkItems(&WvBus);
+    /* Detach from any lower DEVICE_OBJECT */
+    if (WvBus.LowerDeviceObject)
+      IoDetachDevice(WvBus.LowerDeviceObject);
+    /* Delete. */
+    IoDeleteDevice(WvBus.Fdo);
+    /* Disassociate. */
+    WvBus.Fdo = NULL;
     return;
   }
 
index d08acf8..f75f9a4 100644 (file)
@@ -120,13 +120,6 @@ static NTSTATUS STDCALL WvlBusPnpRemoveDev(IN WVL_SP_BUS_T bus, IN PIRP irp) {
         ObDereferenceObject(node->BusPrivate_.Pdo);
         bus->BusPrivate_.NodeCount--;
       }
-    /* Detach from any lower DEVICE_OBJECT */
-    if (lower)
-      IoDetachDevice(lower);
-    /* Delete. */
-    IoDeleteDevice(bus->Fdo);
-    /* Disassociate. */
-    bus->Fdo = NULL;
     /* Stop the thread. */
     bus->Stop = TRUE;
     return status;