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.

208 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1992-1993 Microsoft Corporation
  3. Module Name:
  4. irps.c
  5. Abstract:
  6. Author:
  7. Thomas Dimitri (tommyd) 08-May-1992
  8. --*/
  9. #include "asyncall.h"
  10. #include "globals.h"
  11. VOID
  12. AsyncCancelQueued(
  13. PDEVICE_OBJECT DeviceObject,
  14. PIRP Irp)
  15. {
  16. DbgTracef(0, ("RASHUB: IRP 0x%.8x is being cancelled.\n", Irp));
  17. // Mark this Irp as cancelled
  18. Irp->IoStatus.Status = STATUS_CANCELLED;
  19. Irp->IoStatus.Information = 0;
  20. // Take off our own list
  21. RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
  22. // Release cancel spin lock which the IO system acquired??
  23. IoReleaseCancelSpinLock(Irp->CancelIrql);
  24. IoCompleteRequest(
  25. Irp,
  26. IO_NETWORK_INCREMENT);
  27. }
  28. VOID
  29. AsyncCancelAllQueued(
  30. PLIST_ENTRY QueueToCancel)
  31. {
  32. KIRQL oldIrql;
  33. PLIST_ENTRY headOfList;
  34. PIRP pIrp;
  35. //
  36. // We are pigs here using the global spin lock
  37. // but this is called so infrequently, we can
  38. // be pigs
  39. //
  40. IoAcquireCancelSpinLock(&oldIrql);
  41. //
  42. // Run through entire list until it is empty
  43. //
  44. for (;;) {
  45. if (IsListEmpty(QueueToCancel)) {
  46. break;
  47. }
  48. //
  49. // pick off the head of the list
  50. //
  51. headOfList = RemoveHeadList(QueueToCancel);
  52. pIrp = CONTAINING_RECORD(
  53. headOfList,
  54. IRP,
  55. Tail.Overlay.ListEntry);
  56. //
  57. // Disable the cancel routine
  58. //
  59. IoSetCancelRoutine(
  60. pIrp,
  61. NULL);
  62. //
  63. // Mark this irp as cancelled
  64. //
  65. pIrp->Cancel = TRUE;
  66. pIrp->IoStatus.Status = STATUS_CANCELLED;
  67. pIrp->IoStatus.Information = 0;
  68. //
  69. // We must release the spin lock before calling completing the irp
  70. //
  71. IoReleaseCancelSpinLock(oldIrql);
  72. DbgTracef(0, ("RASHUB: Cancelling a request\n"));
  73. IoCompleteRequest(
  74. pIrp,
  75. IO_NETWORK_INCREMENT);
  76. DbgTracef(0, ("RASHUB: Done cancelling a request\n"));
  77. //
  78. // Acquire it again before looking at the list
  79. //
  80. IoAcquireCancelSpinLock(&oldIrql);
  81. }
  82. IoReleaseCancelSpinLock(oldIrql);
  83. }
  84. VOID
  85. AsyncQueueIrp(
  86. PLIST_ENTRY Queue,
  87. PIRP Irp)
  88. {
  89. KIRQL oldIrql;
  90. //
  91. // We are pigs here using the global spin lock
  92. //
  93. IoAcquireCancelSpinLock(&oldIrql);
  94. //
  95. // Mark the irp as pending and return from this ioctl
  96. //
  97. Irp->IoStatus.Status = STATUS_PENDING;
  98. IoMarkIrpPending(Irp);
  99. //
  100. // Queue up the irp at the end
  101. //
  102. InsertTailList(
  103. Queue,
  104. &Irp->Tail.Overlay.ListEntry);
  105. //
  106. // Set the cancel routine (also the purge routine)
  107. //
  108. IoSetCancelRoutine(
  109. Irp,
  110. AsyncCancelQueued);
  111. IoReleaseCancelSpinLock(oldIrql);
  112. }
  113. BOOLEAN
  114. TryToCompleteDDCDIrp(
  115. PASYNC_INFO pInfo)
  116. /*++
  117. Routine Description:
  118. Arguments:
  119. Return Value:
  120. --*/
  121. {
  122. KIRQL oldIrql;
  123. PLIST_ENTRY headOfList;
  124. PIRP pIrp;
  125. IoAcquireCancelSpinLock(&oldIrql);
  126. if (IsListEmpty(&pInfo->DDCDQueue)) {
  127. IoReleaseCancelSpinLock(oldIrql);
  128. return((BOOLEAN)FALSE);
  129. }
  130. headOfList = RemoveHeadList(&pInfo->DDCDQueue);
  131. pIrp = CONTAINING_RECORD(
  132. headOfList,
  133. IRP,
  134. Tail.Overlay.ListEntry);
  135. IoSetCancelRoutine(
  136. pIrp,
  137. NULL);
  138. pIrp->IoStatus.Status = STATUS_SUCCESS;
  139. pIrp->IoStatus.Information = 0;
  140. IoReleaseCancelSpinLock(oldIrql);
  141. IoCompleteRequest(
  142. pIrp,
  143. IO_NETWORK_INCREMENT);
  144. return((BOOLEAN)TRUE);
  145. }