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.

178 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name :
  4. uldisconnect.cxx
  5. Abstract:
  6. UL_DISCONNECT_CONTEXT implementation
  7. Author:
  8. Bilal Alam (balam) 15-Feb-2000
  9. Environment:
  10. Win32 - User Mode
  11. Project:
  12. W3DT.DLL
  13. --*/
  14. #include "precomp.hxx"
  15. extern PFN_ULATQ_DISCONNECT g_pfnDisconnect;
  16. //
  17. // UL_DISCONNECT_CONTEXT statics
  18. //
  19. LONG UL_DISCONNECT_CONTEXT::sm_cOutstanding;
  20. ALLOC_CACHE_HANDLER * UL_DISCONNECT_CONTEXT::sm_pachDisconnects;
  21. VOID
  22. UL_DISCONNECT_CONTEXT::DoWork(
  23. DWORD cbData,
  24. DWORD dwError,
  25. LPOVERLAPPED lpo
  26. )
  27. /*++
  28. Routine Description:
  29. Handles async calls to UlWaitForDisconnect
  30. Arguments:
  31. cbData - Amount of data on the completion (should be 0)
  32. dwError - Error on the completion
  33. lpo - overlapped
  34. Return Value:
  35. None
  36. --*/
  37. {
  38. DBG_ASSERT( CheckSignature() );
  39. //
  40. // Our handling is simple. We just call the disconnection completion
  41. // routine with the context passed thru UlAtqWaitForDisconnect
  42. //
  43. DBG_ASSERT( g_pfnDisconnect != NULL );
  44. g_pfnDisconnect( _pvContext );
  45. //
  46. // We're done with the context, delete it now
  47. //
  48. delete this;
  49. }
  50. //static
  51. VOID
  52. UL_DISCONNECT_CONTEXT::WaitForOutstandingDisconnects(
  53. VOID
  54. )
  55. /*++
  56. Routine Description:
  57. Wait for the outstanding UL_DISCONNECT_CONTEXTs to drain. This will
  58. happen when we close the AppPool handle to begin shutdown
  59. Arguments:
  60. None
  61. Return Value:
  62. None
  63. --*/
  64. {
  65. while ( sm_cOutstanding != 0 )
  66. {
  67. DBGPRINTF(( DBG_CONTEXT,
  68. "Waiting for %d disconnect contexts to drain\n",
  69. sm_cOutstanding ));
  70. Sleep( 1000 );
  71. }
  72. }
  73. //static
  74. HRESULT
  75. UL_DISCONNECT_CONTEXT::Initialize(
  76. VOID
  77. )
  78. /*++
  79. Routine Description:
  80. Initialize disconnect globals
  81. Arguments:
  82. None
  83. Return Value:
  84. HRESULT
  85. --*/
  86. {
  87. ALLOC_CACHE_CONFIGURATION acConfig;
  88. HRESULT hr = NO_ERROR;
  89. //
  90. // Setup allocation lookaside
  91. //
  92. acConfig.nConcurrency = 1;
  93. acConfig.nThreshold = 100;
  94. acConfig.cbSize = sizeof( UL_DISCONNECT_CONTEXT );
  95. DBG_ASSERT( sm_pachDisconnects == NULL );
  96. sm_pachDisconnects = new ALLOC_CACHE_HANDLER( "UL_DISCONNECT_CONTEXT",
  97. &acConfig );
  98. if ( sm_pachDisconnects == NULL )
  99. {
  100. return HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
  101. }
  102. return NO_ERROR;
  103. }
  104. //static
  105. VOID
  106. UL_DISCONNECT_CONTEXT::Terminate(
  107. VOID
  108. )
  109. /*++
  110. Routine Description:
  111. Cleanup disconnect globals
  112. Arguments:
  113. None
  114. Return Value:
  115. None
  116. --*/
  117. {
  118. if ( sm_pachDisconnects != NULL )
  119. {
  120. delete sm_pachDisconnects;
  121. sm_pachDisconnects = NULL;
  122. }
  123. }