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.

141 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name :
  4. UlDisconnect.hxx
  5. Abstract:
  6. Async context for disconnect notification
  7. Author:
  8. Bilal Alam (balam) 7-Jan-2000
  9. Environment:
  10. Win32 - User Mode
  11. Project:
  12. IIS Worker Process (web service)
  13. --*/
  14. #ifndef _ULDISCONNECT_HXX_
  15. #define _ULDISCONNECT_HXX_
  16. #include "asynccontext.hxx"
  17. #include <acache.hxx>
  18. #define UL_DISCONNECT_SIGNATURE CREATE_SIGNATURE( 'ULDs')
  19. #define UL_DISCONNECT_SIGNATURE_FREE CREATE_SIGNATURE( 'ulds')
  20. class UL_DISCONNECT_CONTEXT : public ASYNC_CONTEXT
  21. {
  22. public:
  23. UL_DISCONNECT_CONTEXT(
  24. PVOID pvContext
  25. )
  26. {
  27. _pvContext = pvContext;
  28. _dwSignature = UL_DISCONNECT_SIGNATURE;
  29. _cRefs = 1;
  30. InterlockedIncrement( &sm_cOutstanding );
  31. }
  32. ~UL_DISCONNECT_CONTEXT(
  33. VOID
  34. )
  35. {
  36. InterlockedDecrement( &sm_cOutstanding );
  37. _dwSignature = UL_DISCONNECT_SIGNATURE_FREE;
  38. }
  39. static
  40. VOID
  41. WaitForOutstandingDisconnects(
  42. VOID
  43. );
  44. static
  45. HRESULT
  46. Initialize(
  47. VOID
  48. );
  49. static
  50. VOID
  51. Terminate(
  52. VOID
  53. );
  54. VOID
  55. DoWork(
  56. DWORD cbData,
  57. DWORD dwError,
  58. LPOVERLAPPED lpo
  59. );
  60. BOOL
  61. CheckSignature(
  62. VOID
  63. ) const
  64. {
  65. return _dwSignature == UL_DISCONNECT_SIGNATURE;
  66. }
  67. VOID *
  68. operator new(
  69. size_t size
  70. )
  71. {
  72. if ( size != sizeof( UL_DISCONNECT_CONTEXT ) )
  73. {
  74. DBG_ASSERT( size == sizeof( UL_DISCONNECT_CONTEXT ) );
  75. return NULL;
  76. }
  77. DBG_ASSERT( sm_pachDisconnects != NULL );
  78. return sm_pachDisconnects->Alloc();
  79. }
  80. VOID
  81. operator delete(
  82. VOID * pUlDisconnect
  83. )
  84. {
  85. DBG_ASSERT( pUlDisconnect != NULL );
  86. DBG_ASSERT( sm_pachDisconnects != NULL );
  87. DBG_REQUIRE( sm_pachDisconnects->Free( pUlDisconnect ) );
  88. }
  89. VOID
  90. ReferenceUlDisconnectContext(
  91. VOID
  92. )
  93. {
  94. InterlockedIncrement( &_cRefs );
  95. }
  96. VOID
  97. DereferenceUlDisconnectContext(
  98. VOID
  99. )
  100. {
  101. if ( InterlockedDecrement( &_cRefs ) == 0 )
  102. {
  103. delete this;
  104. }
  105. }
  106. private:
  107. DWORD _dwSignature;
  108. PVOID _pvContext;
  109. LONG _cRefs;
  110. static LONG sm_cOutstanding;
  111. static ALLOC_CACHE_HANDLER* sm_pachDisconnects;
  112. };
  113. #endif