Leaked source code of windows server 2003
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.

85 lines
1.8 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1991 - 1999
  3. Module Name:
  4. clntirp.c
  5. Abstract:
  6. Client IRP queuing routines for CLASSPNP
  7. Environment:
  8. kernel mode only
  9. Notes:
  10. Revision History:
  11. --*/
  12. #include "classp.h"
  13. #include "debug.h"
  14. /*
  15. * EnqueueDeferredClientIrp
  16. *
  17. * Note: we currently do not support Cancel for storage irps.
  18. */
  19. VOID EnqueueDeferredClientIrp(PCLASS_PRIVATE_FDO_DATA FdoData, PIRP Irp)
  20. {
  21. KIRQL oldIrql;
  22. KeAcquireSpinLock(&FdoData->SpinLock, &oldIrql);
  23. InsertTailList(&FdoData->DeferredClientIrpList, &Irp->Tail.Overlay.ListEntry);
  24. KeReleaseSpinLock(&FdoData->SpinLock, oldIrql);
  25. }
  26. /*
  27. * DequeueDeferredClientIrp
  28. *
  29. */
  30. PIRP DequeueDeferredClientIrp(PCLASS_PRIVATE_FDO_DATA FdoData)
  31. {
  32. PIRP irp;
  33. /*
  34. * The DeferredClientIrpList is almost always empty.
  35. * We don't want to grab the spinlock every time we check it (which is on every xfer completion)
  36. * so check once first before we grab the spinlock.
  37. */
  38. if (IsListEmpty(&FdoData->DeferredClientIrpList)){
  39. irp = NULL;
  40. }
  41. else {
  42. PLIST_ENTRY listEntry;
  43. KIRQL oldIrql;
  44. KeAcquireSpinLock(&FdoData->SpinLock, &oldIrql);
  45. if (IsListEmpty(&FdoData->DeferredClientIrpList)){
  46. listEntry = NULL;
  47. }
  48. else {
  49. listEntry = RemoveHeadList(&FdoData->DeferredClientIrpList);
  50. }
  51. KeReleaseSpinLock(&FdoData->SpinLock, oldIrql);
  52. if (listEntry == NULL) {
  53. irp = NULL;
  54. }
  55. else {
  56. irp = CONTAINING_RECORD(listEntry, IRP, Tail.Overlay.ListEntry);
  57. ASSERT(irp->Type == IO_TYPE_IRP);
  58. InitializeListHead(&irp->Tail.Overlay.ListEntry);
  59. }
  60. }
  61. return irp;
  62. }