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.

343 lines
9.6 KiB

  1. /*-----------------------------------------------------------------------------
  2. Copyright (c) 1995-1997 Microsoft Corporation
  3. Module Name :
  4. wamexec.hxx
  5. Abstract:
  6. This module executes a wam request
  7. Author:
  8. David Kaplan ( DaveK ) 11-Mar-1997
  9. Environment:
  10. User Mode - Win32
  11. Project:
  12. W3 services DLL
  13. -----------------------------------------------------------------------------*/
  14. #ifndef __W3SVC_WAMEXEC_HXX__
  15. #define __W3SVC_WAMEXEC_HXX__
  16. #ifndef __W3SVC_WAMINFO_HXX__
  17. #include "waminfo.hxx"
  18. #endif
  19. #include "ptable.hxx"
  20. /*-----------------------------------------------------------------------------
  21. * Forward references
  22. -----------------------------------------------------------------------------*/
  23. class MB;
  24. /*-----------------------------------------------------------------------------
  25. class WAM_DICTATOR
  26. Class definition for the WAM_DICTATOR object.
  27. Members:
  28. m_pMetabase
  29. m_Hash
  30. m_DyingListHead
  31. m_cRef
  32. m_hW3SVCProcess
  33. m_fCleanupInProcess
  34. m_fShutdownInProgress
  35. m_csWamCreation
  36. m_csDyingList
  37. -----------------------------------------------------------------------------*/
  38. class WAM_DICTATOR
  39. {
  40. private:
  41. MB* m_pMetabase; // Metabase Object
  42. LONG m_cRef; // Reference count
  43. BOOL m_fCleanupInProgress;
  44. BOOL m_fShutdownInProgress;
  45. HANDLE m_hW3Svc; // Handle of the W3Svc process
  46. DWORD m_dwScheduledId; // ScheduledWorkItem() 's cookie.
  47. // Access and changed of this value should be
  48. // within a Critical Section.
  49. CRITICAL_SECTION m_csWamCreation;
  50. CRITICAL_SECTION m_csDyingList;
  51. STR m_strRootAppPath;
  52. LIST_ENTRY m_DyingListHead; // dying list
  53. public:
  54. CProcessTable m_PTable;
  55. private:
  56. DWORD m_pidInetInfo;
  57. SV_CACHE_MAP m_ServerVariableMap;
  58. CReaderWriterLock3 m_HashTableLock;
  59. CWamInfoHash m_HashTable;
  60. public:
  61. WAM_DICTATOR();
  62. ~WAM_DICTATOR();
  63. HRESULT InitWamDictator();
  64. HRESULT StartShutdown();
  65. HRESULT UninitWamDictator();
  66. LONG Reference();
  67. LONG Dereference();
  68. const SV_CACHE_MAP &
  69. QueryServerVariableMap( VOID ) const
  70. {
  71. return m_ServerVariableMap;
  72. }
  73. HRESULT ProcessWamRequest
  74. (
  75. HTTP_REQUEST * pHttpRequest,
  76. EXEC_DESCRIPTOR * pExec,
  77. const STR * pstrPath,
  78. BOOL * pfHandled,
  79. BOOL * pfFinished
  80. );
  81. // Sink Function.
  82. HRESULT WamRegSink
  83. (
  84. LPCSTR szAppPath,
  85. const DWORD dwCommand,
  86. DWORD* pdwResult
  87. );
  88. // Diagnostics methods
  89. BOOL DumpWamDictatorInfo
  90. (
  91. OUT CHAR * pchBuffer,
  92. IN OUT LPDWORD lpcchBuffer
  93. );
  94. // Query handle to W3SVC
  95. HANDLE HW3SvcProcess();
  96. static VOID WINAPI CleanupScheduled(VOID *pContext); // Clean up WamInfo on the DyingList.
  97. HRESULT CleanUpDyingList(VOID);
  98. MB *PMetabase(VOID);
  99. STR *QueryDefaultAppPath(VOID); // always return a pointer to STR("/LM/W3SVC").
  100. inline
  101. DWORD QueryInetInfoPid(VOID)
  102. {
  103. return m_pidInetInfo;
  104. }
  105. HRESULT UnLoadWamInfo
  106. (
  107. STR *pstrWamPath,
  108. BOOL fCPUPause,
  109. BOOL *pfAppCpuUnloaded = NULL
  110. );
  111. VOID CPUResumeWamInfo
  112. (
  113. STR *pstrWamPath
  114. );
  115. VOID CPUUpdateWamInfo
  116. (
  117. STR *pstrAppPath
  118. );
  119. static VOID StopApplicationsByInstance
  120. (
  121. VOID *pContext // W3_SERVER_INSTANCE *pInstance
  122. );
  123. VOID HashReadLock(VOID);
  124. VOID HashReadUnlock(VOID);
  125. VOID HashWriteLock(VOID);
  126. VOID HashWriteUnlock(VOID);
  127. BOOL DeleteWamInfoFromHashTable
  128. (
  129. CWamInfo * pWamInfo
  130. );
  131. BOOL FIsShutdown();
  132. private:
  133. // ------------------------------------------------------------
  134. // Private Functions of CWamInfo
  135. // ------------------------------------------------------------
  136. HRESULT GetWamInfo
  137. (
  138. const STR* pstrMetabasePath,
  139. const HTTP_REQUEST* pHttpRequest,
  140. CWamInfo ** ppWamInfo
  141. );
  142. HRESULT CreateWamInfo
  143. (
  144. const STR & strAppRootPath,
  145. CWamInfo ** ppWamInfo,
  146. PW3_SERVER_INSTANCE pwsiInstance
  147. );
  148. INT FindWamInfo
  149. (
  150. const STR * pstrMetabasePath,
  151. CWamInfo ** ppWamInfo
  152. );
  153. BOOL AddWamInfo
  154. (
  155. CWamInfo* pWamInfo
  156. );
  157. HRESULT ShutdownWamInfo
  158. (
  159. CWamInfo* pWamInfo,
  160. INT cIgnoreRefs
  161. );
  162. LK_PREDICATE DeleteIfTimeOut
  163. (
  164. CWamInfo* pWamInfo,
  165. void* pvState
  166. );
  167. HRESULT MDGetAppVariables
  168. (
  169. LPCSTR szMetabasePath,
  170. BOOL* pfAllowAppToRun,
  171. CLSID* pclsidWam,
  172. BOOL* pfInProcess,
  173. BOOL* pfInPool,
  174. BOOL* pfEnableTryExcept,
  175. DWORD *pdwOOPCrashThreshold,
  176. BOOL* pfJobEnabled,
  177. WCHAR* wszPackageID,
  178. DWORD* pdwPeriodicRestartRequests,
  179. DWORD* pdwPeriodicRestartTime,
  180. MULTISZ*pmszPeriodicRestartSchedule,
  181. DWORD* pdwShutdownTimeLimit
  182. );
  183. HRESULT InsertDyingList
  184. (
  185. CWamInfo* pWamInfo,
  186. BOOL fNeedReference = TRUE
  187. );
  188. void CreateWam_Lock(void);
  189. void CreateWam_UnLock(void);
  190. void ScheduledId_Lock();
  191. void ScheduledId_UnLock();
  192. void DyingList_Lock(void);
  193. void DyingList_UnLock(void);
  194. static LK_PREDICATE DeleteInShutdown
  195. (
  196. CWamInfo* pWamInfo,
  197. void* pvState
  198. );
  199. }; // class WAM_DICTATOR
  200. dllexp extern WAM_DICTATOR *g_pWamDictator; // global wam dictator
  201. inline HANDLE WAM_DICTATOR::HW3SvcProcess() { return( m_hW3Svc ); }
  202. inline BOOL WAM_DICTATOR::FIsShutdown() {return m_fShutdownInProgress; }
  203. inline VOID WAM_DICTATOR::CleanupScheduled(VOID *pContext)
  204. {
  205. g_pWamDictator->CleanUpDyingList();
  206. }
  207. inline LK_PREDICATE WAM_DICTATOR::DeleteIfTimeOut
  208. (
  209. CWamInfo* pWamInfo,
  210. void* pvState
  211. )
  212. {
  213. return LKP_PERFORM;
  214. }
  215. inline void WAM_DICTATOR::CreateWam_Lock(void) {EnterCriticalSection(&m_csWamCreation);}
  216. inline void WAM_DICTATOR::CreateWam_UnLock(void) {LeaveCriticalSection(&m_csWamCreation);}
  217. inline void WAM_DICTATOR::ScheduledId_Lock(void) {CreateWam_Lock();};
  218. inline void WAM_DICTATOR::ScheduledId_UnLock(void) {CreateWam_UnLock();};
  219. inline void WAM_DICTATOR::DyingList_Lock(void) {EnterCriticalSection(&m_csDyingList);}
  220. inline void WAM_DICTATOR::DyingList_UnLock(void) {LeaveCriticalSection(&m_csDyingList);}
  221. inline MB *WAM_DICTATOR::PMetabase(void) {return m_pMetabase;}
  222. inline STR *WAM_DICTATOR::QueryDefaultAppPath(void) {return &m_strRootAppPath;}
  223. inline VOID WAM_DICTATOR::HashReadLock(VOID) {m_HashTableLock.ReadLock();}
  224. inline VOID WAM_DICTATOR::HashReadUnlock(VOID) {m_HashTableLock.ReadUnlock();}
  225. inline VOID WAM_DICTATOR::HashWriteLock(VOID) {m_HashTableLock.WriteLock();}
  226. inline VOID WAM_DICTATOR::HashWriteUnlock(VOID) {m_HashTableLock.WriteUnlock();}
  227. /*-----------------------------------------------------------------------------
  228. WAM_DICTATOR::Reference
  229. Increment WAM_DICTATOR reference count.
  230. WARNING: return value of InterlockedIncrement is only -1, 0, 1, and is not Reference. should not use
  231. the return value.
  232. Return:
  233. LONG
  234. -----------------------------------------------------------------------------*/
  235. inline LONG WAM_DICTATOR::Reference()
  236. {
  237. return InterlockedIncrement(&m_cRef);
  238. }
  239. /*-----------------------------------------------------------------------------
  240. WAM_DICTATOR::Dereference
  241. Dereference WAM_DICTATOR
  242. Warning: Should not use the return value.
  243. Return:
  244. LONG
  245. -----------------------------------------------------------------------------*/
  246. inline LONG WAM_DICTATOR::Dereference()
  247. {
  248. DBG_ASSERT(m_cRef > 0);
  249. return InterlockedDecrement(&m_cRef);
  250. }
  251. #define HASH_TABLE_REF 1
  252. #define DYING_LIST_REF 1
  253. #define FIND_KEY_REF 1
  254. /*-----------------------------------------------------------------------------
  255. * Globals
  256. -----------------------------------------------------------------------------*/
  257. extern "C" dllexp BOOL
  258. WamDictatorDumpInfo
  259. (
  260. OUT CHAR * pch,
  261. IN OUT LPDWORD lpcchBuff
  262. );
  263. VOID
  264. RecycleCallback(
  265. VOID * pvContext
  266. );
  267. #endif // __W3SVC_WAMEXEC_HXX__
  268. /************************ End of File ***********************/