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.

175 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,
  24. DWORD,
  25. LPOVERLAPPED
  26. )
  27. /*++
  28. Routine Description:
  29. Handles async calls to UlWaitForDisconnect
  30. Arguments:
  31. All arguments unused
  32. Return Value:
  33. None
  34. --*/
  35. {
  36. DBG_ASSERT( CheckSignature() );
  37. //
  38. // Our handling is simple. We just call the disconnection completion
  39. // routine with the context passed thru UlAtqWaitForDisconnect
  40. //
  41. DBG_ASSERT( g_pfnDisconnect != NULL );
  42. g_pfnDisconnect( _pvContext );
  43. //
  44. // We're done with the context, delete it now
  45. //
  46. DereferenceUlDisconnectContext();
  47. }
  48. //static
  49. VOID
  50. UL_DISCONNECT_CONTEXT::WaitForOutstandingDisconnects(
  51. VOID
  52. )
  53. /*++
  54. Routine Description:
  55. Wait for the outstanding UL_DISCONNECT_CONTEXTs to drain. This will
  56. happen when we close the AppPool handle to begin shutdown
  57. Arguments:
  58. None
  59. Return Value:
  60. None
  61. --*/
  62. {
  63. while ( sm_cOutstanding != 0 )
  64. {
  65. DBGPRINTF(( DBG_CONTEXT,
  66. "Waiting for %d disconnect contexts to drain\n",
  67. sm_cOutstanding ));
  68. Sleep( 1000 );
  69. }
  70. }
  71. //static
  72. HRESULT
  73. UL_DISCONNECT_CONTEXT::Initialize(
  74. VOID
  75. )
  76. /*++
  77. Routine Description:
  78. Initialize disconnect globals
  79. Arguments:
  80. None
  81. Return Value:
  82. HRESULT
  83. --*/
  84. {
  85. ALLOC_CACHE_CONFIGURATION acConfig;
  86. //
  87. // Setup allocation lookaside
  88. //
  89. acConfig.nConcurrency = 1;
  90. acConfig.nThreshold = 100;
  91. acConfig.cbSize = sizeof( UL_DISCONNECT_CONTEXT );
  92. DBG_ASSERT( sm_pachDisconnects == NULL );
  93. sm_pachDisconnects = new ALLOC_CACHE_HANDLER( "UL_DISCONNECT_CONTEXT",
  94. &acConfig );
  95. if ( sm_pachDisconnects == NULL )
  96. {
  97. return HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
  98. }
  99. return NO_ERROR;
  100. }
  101. //static
  102. VOID
  103. UL_DISCONNECT_CONTEXT::Terminate(
  104. VOID
  105. )
  106. /*++
  107. Routine Description:
  108. Cleanup disconnect globals
  109. Arguments:
  110. None
  111. Return Value:
  112. None
  113. --*/
  114. {
  115. if ( sm_pachDisconnects != NULL )
  116. {
  117. delete sm_pachDisconnects;
  118. sm_pachDisconnects = NULL;
  119. }
  120. }