Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.5 KiB

  1. #include "pch.h"
  2. NTSTATUS
  3. PptPdoCleanup(
  4. IN PDEVICE_OBJECT DeviceObject,
  5. IN PIRP Irp
  6. )
  7. /*++
  8. Routine Description:
  9. This routine is the dispatch for a cleanup requests.
  10. Arguments:
  11. DeviceObject - Supplies the device object.
  12. Irp - Supplies the I/O request packet.
  13. Return Value:
  14. STATUS_SUCCESS - Success.
  15. --*/
  16. {
  17. PPDO_EXTENSION pdx = DeviceObject->DeviceExtension;
  18. KIRQL CancelIrql;
  19. PDRIVER_CANCEL CancelRoutine;
  20. PIRP CurrentLastIrp;
  21. DD((PCE)pdx,DDT,"ParCleanup - enter\n");
  22. //
  23. // While the list is not empty, go through and cancel each irp.
  24. //
  25. IoAcquireCancelSpinLock(&CancelIrql);
  26. //
  27. // Clean the list from back to front.
  28. //
  29. while (!IsListEmpty(&pdx->WorkQueue)) {
  30. CurrentLastIrp = CONTAINING_RECORD(pdx->WorkQueue.Blink,
  31. IRP, Tail.Overlay.ListEntry);
  32. RemoveEntryList(pdx->WorkQueue.Blink);
  33. CancelRoutine = CurrentLastIrp->CancelRoutine;
  34. CurrentLastIrp->CancelIrql = CancelIrql;
  35. CurrentLastIrp->CancelRoutine = NULL;
  36. CurrentLastIrp->Cancel = TRUE;
  37. CancelRoutine(DeviceObject, CurrentLastIrp);
  38. IoAcquireCancelSpinLock(&CancelIrql);
  39. }
  40. //
  41. // If there is a current irp then mark it as cancelled.
  42. //
  43. if (pdx->CurrentOpIrp) {
  44. pdx->CurrentOpIrp->Cancel = TRUE;
  45. }
  46. IoReleaseCancelSpinLock(CancelIrql);
  47. P4CompleteRequest( Irp, STATUS_SUCCESS, 0 );
  48. return STATUS_SUCCESS;
  49. }