[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[win-pv-devel] [PATCH 1/4] Call XenIfaceCleanup from IRP_MJ_CLEANUP



XenIfaceCleanup was not called which meant that some watches, event
channels and grant entries were not cleaned up on closing the device
handle and required explicit cleanup. Add a IRP handler to call
XenIfaceCleanup from the IRP_MJ_CLEANUP for a specific FileObject.
This ensures all watches, event channels and grant entries are
destroyed in the event of the caller crashing or not gracefullly
cleaning up objects.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xeniface/fdo.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/xeniface/fdo.c b/src/xeniface/fdo.c
index fa14b5b..ba8d19a 100644
--- a/src/xeniface/fdo.c
+++ b/src/xeniface/fdo.c
@@ -2300,6 +2300,25 @@ FdoDispatchSystemControl(
     return status;
 }
 
+static DECLSPEC_NOINLINE NTSTATUS
+FdoDispatchCleanup(
+    IN  PXENIFACE_FDO   Fdo,
+    IN  PIRP            Irp
+    )
+{
+    PIO_STACK_LOCATION  StackLocation;
+    PFILE_OBJECT        FileObject;
+
+    StackLocation = IoGetCurrentIrpStackLocation(Irp);
+    FileObject = StackLocation->FileObject;
+
+    // XenIfaceCleanup requires PASSIVE_LEVEL as it can call KeFlushQueuedDpcs
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+    XenIfaceCleanup(Fdo, FileObject);
+
+    return FdoDispatchComplete(Fdo, Irp);
+}
+
 NTSTATUS
 FdoDispatch(
     IN  PXENIFACE_FDO   Fdo,
@@ -2328,6 +2347,10 @@ FdoDispatch(
         status = FdoDispatchSystemControl(Fdo, Irp);
         break;
 
+    case IRP_MJ_CLEANUP:
+        status = FdoDispatchCleanup(Fdo, Irp);
+        break;
+
     case IRP_MJ_CREATE:
     case IRP_MJ_CLOSE:
     case IRP_MJ_READ:
-- 
1.9.4.msysgit.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.