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.

283 lines
5.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name :
  4. childcontext.cxx
  5. Abstract:
  6. Child context implementation
  7. Author:
  8. Bilal Alam (balam) 10-Mar-2000
  9. Environment:
  10. Win32 - User Mode
  11. Project:
  12. ULW3.DLL
  13. --*/
  14. #include "precomp.hxx"
  15. ALLOC_CACHE_HANDLER * W3_CHILD_CONTEXT::sm_pachChildContexts;
  16. W3_CHILD_CONTEXT::W3_CHILD_CONTEXT(
  17. W3_MAIN_CONTEXT * pMainContext,
  18. W3_CONTEXT * pParentContext,
  19. W3_REQUEST * pRequest,
  20. BOOL fOwnRequest,
  21. W3_USER_CONTEXT * pCustomUserContext,
  22. DWORD dwExecFlags,
  23. BOOL fContinueStarScriptMapChain,
  24. DWORD dwRecursionLevel
  25. )
  26. : W3_CONTEXT( dwExecFlags, dwRecursionLevel ),
  27. _pMainContext( pMainContext ),
  28. _pParentContext( pParentContext ),
  29. _pRequest( pRequest ),
  30. _fOwnRequest( fOwnRequest ),
  31. _pCustomUserContext( pCustomUserContext )
  32. {
  33. //
  34. // If the parent context is disabling wildcards, custom errors, or
  35. // headers --> we should ensure those features are disabled for
  36. // this context too
  37. //
  38. DBG_ASSERT( _pParentContext != NULL );
  39. if ( !_pParentContext->QuerySendCustomError() )
  40. {
  41. _dwExecFlags |= W3_FLAG_NO_CUSTOM_ERROR;
  42. }
  43. if ( !_pParentContext->QuerySendHeaders() )
  44. {
  45. _dwExecFlags |= W3_FLAG_NO_HEADERS;
  46. }
  47. if ( !_pParentContext->QuerySendErrorBody() )
  48. {
  49. _dwExecFlags |= W3_FLAG_NO_ERROR_BODY;
  50. }
  51. //
  52. // Get to the next *-ScriptMap
  53. //
  54. if (fContinueStarScriptMapChain)
  55. {
  56. _CurrentStarScriptMapIndex = _pParentContext->QueryCurrentStarScriptMapIndex() + 1;
  57. }
  58. else
  59. {
  60. _CurrentStarScriptMapIndex = 0;
  61. }
  62. //
  63. // Get the fAuthAccessCheckRequired flag from the main context so
  64. // the child conext would know if we need to do auth access check
  65. // or not.
  66. //
  67. DBG_ASSERT( _pMainContext != NULL );
  68. SetAuthAccessCheckRequired( _pMainContext->
  69. QueryAuthAccessCheckRequired() );
  70. }
  71. W3_CHILD_CONTEXT::~W3_CHILD_CONTEXT()
  72. /*++
  73. Routine Description:
  74. Deletes a child context.
  75. Arguments:
  76. None
  77. Return Value:
  78. None
  79. --*/
  80. {
  81. if ( _pUrlContext != NULL )
  82. {
  83. delete _pUrlContext;
  84. _pUrlContext = NULL;
  85. }
  86. //
  87. // Only delete the request object if we own it! (we won't own it in
  88. // case where we're doing a "reprocessurl"
  89. //
  90. if ( _pRequest )
  91. {
  92. if ( _fOwnRequest )
  93. {
  94. delete _pRequest;
  95. _pRequest = NULL;
  96. }
  97. }
  98. //
  99. // Clean up the custom user context if there is one
  100. //
  101. if ( _pCustomUserContext != NULL )
  102. {
  103. _pCustomUserContext->DereferenceUserContext();
  104. _pCustomUserContext = NULL;
  105. }
  106. }
  107. // static
  108. HRESULT
  109. W3_CHILD_CONTEXT::Initialize(
  110. VOID
  111. )
  112. /*++
  113. Routine Description:
  114. Global initialization routine for W3_CHILD_CONTEXTs
  115. Arguments:
  116. None
  117. Return Value:
  118. HRESULT
  119. --*/
  120. {
  121. ALLOC_CACHE_CONFIGURATION acConfig;
  122. HRESULT hr = NO_ERROR;
  123. //
  124. // Setup allocation lookaside
  125. //
  126. acConfig.nConcurrency = 1;
  127. acConfig.nThreshold = 100;
  128. acConfig.cbSize = sizeof( W3_CHILD_CONTEXT );
  129. DBG_ASSERT( sm_pachChildContexts == NULL );
  130. sm_pachChildContexts = new ALLOC_CACHE_HANDLER( "W3_CHILD_CONTEXT",
  131. &acConfig );
  132. if ( sm_pachChildContexts == NULL )
  133. {
  134. return HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
  135. }
  136. return NO_ERROR;
  137. }
  138. // static
  139. VOID
  140. W3_CHILD_CONTEXT::Terminate(
  141. VOID
  142. )
  143. /*++
  144. Routine Description:
  145. Terminate MAIN_CONTEXT globals
  146. Arguments:
  147. None
  148. Return Value:
  149. None
  150. --*/
  151. {
  152. if ( sm_pachChildContexts != NULL )
  153. {
  154. delete sm_pachChildContexts;
  155. sm_pachChildContexts = NULL;
  156. }
  157. }
  158. HRESULT
  159. W3_CHILD_CONTEXT::RetrieveUrlContext(
  160. BOOL * pfFinished
  161. )
  162. /*++
  163. Routine Description:
  164. Retrieves URL context for this context
  165. Arguments:
  166. pfFinished - Set to TRUE if filter wants out
  167. Return Value:
  168. HRESULT
  169. --*/
  170. {
  171. URL_CONTEXT * pUrlContext;
  172. HRESULT hr;
  173. if ( pfFinished == NULL )
  174. {
  175. DBG_ASSERT( FALSE );
  176. return HRESULT_FROM_WIN32( ERROR_INVALID_PARAMETER );
  177. }
  178. *pfFinished = FALSE;
  179. QueryMainContext()->PushCurrentContext( this );
  180. hr = URL_CONTEXT::RetrieveUrlContext( this,
  181. QueryRequest(),
  182. &pUrlContext,
  183. pfFinished );
  184. QueryMainContext()->PopCurrentContext();
  185. if ( FAILED( hr ) )
  186. {
  187. return hr;
  188. }
  189. if ( *pfFinished )
  190. {
  191. return NO_ERROR;
  192. }
  193. DBG_ASSERT( pUrlContext != NULL );
  194. _pUrlContext = pUrlContext;
  195. //
  196. // Make sure we skip over any ignored *-ScriptMaps
  197. //
  198. META_SCRIPT_MAP *pScriptMap = _pUrlContext->QueryMetaData()->QueryScriptMap();
  199. META_SCRIPT_MAP_ENTRY *pScriptMapEntry;
  200. while (TRUE)
  201. {
  202. pScriptMapEntry = pScriptMap->QueryStarScriptMap( _CurrentStarScriptMapIndex );
  203. if (pScriptMapEntry == NULL ||
  204. !QueryMainContext()->IsIgnoredInterceptor(*pScriptMapEntry->QueryExecutable()))
  205. {
  206. break;
  207. }
  208. _CurrentStarScriptMapIndex++;
  209. }
  210. return NO_ERROR;
  211. }