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.

196 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name :
  4. AppPool.cxx
  5. Abstract:
  6. Defines the functions used to access the data channel.
  7. Author:
  8. Murali R. Krishnan ( MuraliK ) 20-Oct-1998
  9. Lei Jin ( leijin ) 13-Apr-1999 Porting
  10. Project:
  11. IIS Worker Process
  12. --*/
  13. #include "precomp.hxx"
  14. #include "AppPool.hxx"
  15. #include "RwpFunctions.hxx"
  16. UL_APP_POOL::UL_APP_POOL(
  17. VOID
  18. ) : _hAppPool( NULL )
  19. {
  20. }
  21. UL_APP_POOL::~UL_APP_POOL(
  22. VOID
  23. )
  24. {
  25. Cleanup();
  26. }
  27. HRESULT
  28. UL_APP_POOL::Initialize(
  29. LPCWSTR pwszAppPoolName
  30. )
  31. /*++
  32. Routine Description:
  33. Initialize UL AppPool
  34. Arguments:
  35. pwszAppPoolName - AppPool Name
  36. Return Value:
  37. HRESULT
  38. --*/
  39. {
  40. //WCHAR pwszRWPAppPoolName[MAX_PATH];
  41. ULONG rc;
  42. if ( _hAppPool != NULL )
  43. {
  44. DBGPRINTF(( DBG_CONTEXT,
  45. "AppPool already open!\n" ));
  46. return HRESULT_FROM_WIN32( ERROR_DUP_NAME );
  47. }
  48. _Lock.WriteLock();
  49. if(RWP_AppPoolTest())
  50. {
  51. // open app pool with alternate name
  52. rc = HttpOpenAppPool( &_hAppPool,
  53. L"fdwqofjew", // just use random bogus name
  54. 0 );
  55. }
  56. else
  57. {
  58. rc = HttpOpenAppPool( &_hAppPool,
  59. pwszAppPoolName,
  60. 0 );
  61. }
  62. _Lock.WriteUnlock();
  63. if ( rc != NO_ERROR )
  64. {
  65. DBGPRINTF(( DBG_CONTEXT,
  66. "Failed to open AppPool '%ws'. rc = %d\n",
  67. pwszAppPoolName,
  68. rc ));
  69. return HRESULT_FROM_WIN32( rc );
  70. }
  71. return NO_ERROR;
  72. }
  73. HRESULT
  74. UL_APP_POOL::Cleanup(
  75. VOID
  76. )
  77. /*++
  78. Routine Description:
  79. Close data channel
  80. Arguments:
  81. None
  82. Return Value:
  83. HRESULT
  84. --*/
  85. {
  86. HRESULT hr = NO_ERROR;
  87. HANDLE hAppPool = NULL;
  88. if ( _hAppPool != NULL )
  89. {
  90. _Lock.WriteLock();
  91. hAppPool = _hAppPool;
  92. _hAppPool = NULL;
  93. _Lock.WriteUnlock();
  94. DBG_ASSERT( hAppPool != NULL );
  95. if ( !CloseHandle( hAppPool ) )
  96. {
  97. hr = HRESULT_FROM_WIN32( GetLastError() );
  98. }
  99. }
  100. return hr;
  101. }
  102. HANDLE
  103. UL_APP_POOL::QueryAndLockHandle(
  104. VOID
  105. )
  106. /*++
  107. Routine Description:
  108. Read locks and returns the handle.
  109. Arguments:
  110. None
  111. Return Value:
  112. HANDLE
  113. --*/
  114. {
  115. _Lock.ReadLock();
  116. return _hAppPool;
  117. }
  118. HRESULT
  119. UL_APP_POOL::UnlockHandle(
  120. VOID
  121. )
  122. /*++
  123. Routine Description:
  124. Read unlocks.
  125. Arguments:
  126. None
  127. Return Value:
  128. HRESULT
  129. --*/
  130. {
  131. DBG_ASSERT(_Lock.IsReadLocked());
  132. _Lock.ReadUnlock();
  133. return S_OK;
  134. }