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.

442 lines
7.6 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. w3server.h
  5. Abstract:
  6. Type definition for worker process implementation of IIS.
  7. Author:
  8. Taylor Weiss (TaylorW) 16-Dec-1999
  9. Revision History:
  10. At this point - the following features of the IIS5 code base are
  11. considered obsolete (ie never to be part of IIS+):
  12. 1. Service control manager goo
  13. 2. RPC administration support
  14. 3. Down-level admin support
  15. 4. Socket/Endpoint goo
  16. 5. Direct handling of site - start/stop/pause/etc
  17. 6. Password change support (ie. .htr hooks).
  18. --*/
  19. #ifndef _W3SERVER_H_
  20. #define _W3SERVER_H_
  21. /************************************************************
  22. * Include Headers
  23. ************************************************************/
  24. #include "mb_notify.h"
  25. /************************************************************
  26. * Type Definitions
  27. ************************************************************/
  28. #define W3_SERVER_MB_PATH L"/LM/W3SVC/"
  29. #define W3_SERVER_MB_PATH_CCH 10
  30. class W3_SITE;
  31. /*++
  32. class W3_SERVER
  33. Encapsulates global settings for an HTTP server run in
  34. a duct-tape worker process.
  35. Condenses the relevant functionality exposed in IIS
  36. through the IIS_SERVICE and W3_IIS_SERVICE.
  37. --*/
  38. #define W3_SERVER_SIGNATURE 'VRSW'
  39. #define W3_SERVER_FREE_SIGNATURE 'fRSW'
  40. /*++
  41. class W3_SITE_LIST
  42. The list of sites serviced by a W3_SERVER.
  43. --*/
  44. class W3_SITE_LIST :
  45. public CTypedHashTable<W3_SITE_LIST, W3_SITE, DWORD>
  46. {
  47. public:
  48. W3_SITE_LIST() :
  49. CTypedHashTable<W3_SITE_LIST, W3_SITE, DWORD>("W3_SITE_LIST")
  50. {}
  51. static DWORD
  52. ExtractKey(const W3_SITE *site);
  53. static DWORD
  54. CalcKeyHash(const DWORD key)
  55. {
  56. return key;
  57. }
  58. static bool
  59. EqualKeys(DWORD key1, DWORD key2)
  60. {
  61. return key1 == key2;
  62. }
  63. static VOID
  64. AddRefRecord(W3_SITE *site, int nIncr);
  65. };
  66. class W3_METADATA_CACHE;
  67. class W3_URL_INFO_CACHE;
  68. class UL_RESPONSE_CACHE;
  69. class W3_SERVER
  70. {
  71. //
  72. // CODEWORK
  73. // Using friends to keep the public interface of this
  74. // class as clean as possible. It's pretty sleazy so
  75. // we definitely should undo if it isn't valuable.
  76. //
  77. friend class MB_LISTENER;
  78. public:
  79. W3_SERVER( BOOL fCompatibilityMode );
  80. ~W3_SERVER();
  81. HRESULT
  82. Initialize(
  83. INT argc,
  84. LPWSTR argv[]
  85. );
  86. VOID
  87. Terminate(
  88. HRESULT hrReason
  89. );
  90. HRESULT
  91. StartListen(
  92. VOID
  93. );
  94. IMSAdminBase *
  95. QueryMDObject(
  96. VOID
  97. ) const
  98. {
  99. // This is only valid if all are threads are CoInited
  100. // in the MTA
  101. return m_pMetaBase;
  102. }
  103. LPCWSTR
  104. QueryMDPath(
  105. VOID
  106. ) const
  107. {
  108. return W3_SERVER_MB_PATH;
  109. }
  110. TOKEN_CACHE *
  111. QueryTokenCache(
  112. VOID
  113. ) const
  114. {
  115. return m_pTokenCache;
  116. }
  117. W3_FILE_INFO_CACHE *
  118. QueryFileCache(
  119. VOID
  120. ) const
  121. {
  122. return m_pFileCache;
  123. }
  124. W3_URL_INFO_CACHE *
  125. QueryUrlInfoCache(
  126. VOID
  127. ) const
  128. {
  129. return m_pUrlInfoCache;
  130. }
  131. W3_METADATA_CACHE *
  132. QueryMetaCache(
  133. VOID
  134. ) const
  135. {
  136. return m_pMetaCache;
  137. }
  138. UL_RESPONSE_CACHE *
  139. QueryUlCache(
  140. VOID
  141. ) const
  142. {
  143. return m_pUlCache;
  144. }
  145. DWORD
  146. QuerySystemChangeNumber(
  147. VOID
  148. ) const
  149. {
  150. return m_dwSystemChangeNumber;
  151. }
  152. W3_SITE *
  153. FindSite(
  154. IN DWORD dwInstance
  155. );
  156. BOOL
  157. AddSite(
  158. IN W3_SITE * pInstance,
  159. IN bool fOverWrite = false
  160. );
  161. BOOL
  162. RemoveSite(
  163. IN W3_SITE * pInstance
  164. );
  165. VOID
  166. DestroyAllSites(
  167. VOID
  168. );
  169. VOID WriteLockSiteList()
  170. {
  171. m_pSiteList->WriteLock();
  172. }
  173. VOID WriteUnlockSiteList()
  174. {
  175. m_pSiteList->WriteUnlock();
  176. }
  177. HRESULT CollectCounters(
  178. PBYTE * ppCounterData,
  179. DWORD * pdwCounterData
  180. );
  181. HRESULT
  182. LoadString(
  183. DWORD dwStringID,
  184. CHAR * pszString,
  185. DWORD * pcbString
  186. );
  187. VOID
  188. GetCacheStatistics(
  189. IISWPGlobalCounters * pCacheCtrs
  190. );
  191. BOOL
  192. QueryInBackwardCompatibilityMode(
  193. VOID
  194. )
  195. {
  196. return m_fInBackwardCompatibilityMode;
  197. }
  198. HRESULT
  199. ReadUseDigestSSP(
  200. VOID
  201. );
  202. BOOL
  203. QueryUseDigestSSP(
  204. VOID
  205. )
  206. {
  207. return m_fUseDigestSSP;
  208. }
  209. CHAR *
  210. QueryComputerName()
  211. {
  212. return m_pszComputerName;
  213. }
  214. USHORT
  215. QueryComputerNameLength()
  216. {
  217. return m_cchComputerName;
  218. }
  219. void LogEvent(IN DWORD idMessage,
  220. IN WORD cSubStrings,
  221. IN const WCHAR *apszSubStrings[],
  222. IN DWORD errCode = 0)
  223. {
  224. m_EventLog.LogEvent(idMessage,
  225. cSubStrings,
  226. apszSubStrings,
  227. errCode);
  228. }
  229. static
  230. VOID
  231. OnShutdown(
  232. BOOL fDoImmediate
  233. );
  234. static
  235. VOID
  236. FlushUlResponses(
  237. MULTISZ * pmszUrls
  238. );
  239. private:
  240. //
  241. // Metabase change handlers
  242. //
  243. HRESULT
  244. MetabaseChangeNotification(
  245. DWORD dwMDNumElements,
  246. MD_CHANGE_OBJECT pcoChangeList[]
  247. );
  248. HRESULT
  249. HandleMetabaseChange(
  250. const MD_CHANGE_OBJECT & ChangeObject
  251. );
  252. HRESULT
  253. InitializeCaches(
  254. VOID
  255. );
  256. VOID
  257. TerminateCaches(
  258. VOID
  259. );
  260. //
  261. // Internal Types
  262. //
  263. enum INIT_STATUS {
  264. INIT_NONE,
  265. INIT_SHUTDOWN_EVENT,
  266. INIT_IISUTIL,
  267. INIT_WINSOCK,
  268. INIT_METABASE,
  269. INIT_MB_LISTENER,
  270. INIT_FILTERS,
  271. INIT_W3_SITE,
  272. INIT_SITE_LIST,
  273. INIT_ULATQ,
  274. INIT_CACHES,
  275. INIT_W3_CONNECTION,
  276. INIT_W3_CONTEXT,
  277. INIT_W3_REQUEST,
  278. INIT_W3_RESPONSE,
  279. INIT_SERVER_VARIABLES,
  280. INIT_MIME_MAP,
  281. INIT_LOGGING,
  282. INIT_RAW_CONNECTION,
  283. INIT_CERTIFICATE_CONTEXT,
  284. INIT_HTTP_COMPRESSION,
  285. INIT_SERVER
  286. };
  287. DWORD m_Signature;
  288. //
  289. // How far have we initialized?
  290. //
  291. INIT_STATUS m_InitStatus;
  292. //
  293. // All important pointer to ABO
  294. //
  295. IMSAdminBase * m_pMetaBase;
  296. //
  297. // Site list
  298. //
  299. W3_SITE_LIST * m_pSiteList;
  300. //
  301. // Metabase change nofication object
  302. //
  303. MB_LISTENER * m_pMetabaseListener;
  304. //
  305. // event log
  306. //
  307. EVENT_LOG m_EventLog;
  308. //
  309. // Are we in backward compatibility mode?
  310. //
  311. BOOL m_fInBackwardCompatibilityMode;
  312. //
  313. // Do we use new Digest SSP?
  314. //
  315. BOOL m_fUseDigestSSP;
  316. //
  317. // Number of current sites
  318. //
  319. DWORD m_cSites;
  320. //
  321. // The buffer used to put in all the site and global counters in to
  322. // pass to WAS
  323. //
  324. PBYTE m_pCounterDataBuffer;
  325. DWORD m_dwCounterDataBuffer;
  326. //
  327. // The server's name
  328. //
  329. CHAR m_pszComputerName[MAX_COMPUTERNAME_LENGTH + 1];
  330. USHORT m_cchComputerName;
  331. //
  332. // All our caches
  333. //
  334. TOKEN_CACHE * m_pTokenCache;
  335. W3_FILE_INFO_CACHE* m_pFileCache;
  336. W3_METADATA_CACHE * m_pMetaCache;
  337. W3_URL_INFO_CACHE * m_pUrlInfoCache;
  338. UL_RESPONSE_CACHE * m_pUlCache;
  339. //
  340. // :-( System change number. Tie it to sink for perf reasons
  341. //
  342. DWORD m_dwSystemChangeNumber;
  343. };
  344. extern W3_SERVER * g_pW3Server;
  345. #endif // _W3SERVER_H_