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.

275 lines
6.4 KiB

  1. /*++
  2. Copyright (c) 1998-2002 Microsoft Corporation
  3. Module Name:
  4. cachep.h
  5. Abstract:
  6. The private definition of response cache interfaces.
  7. Author:
  8. Michael Courage (mcourage) 17-May-1999
  9. Revision History:
  10. --*/
  11. #ifndef _CACHEP_H_
  12. #define _CACHEP_H_
  13. //
  14. // constants
  15. //
  16. #define CACHE_ENTRY_AGE_THRESHOLD 1
  17. #define ZOMBIE_AGE_THRESHOLD 5
  18. typedef enum _UL_CACHE_PREDICATE
  19. {
  20. ULC_ABORT = 1, // Stop walking the table immediately
  21. ULC_NO_ACTION = 2, // No action, just keep walking
  22. ULC_DELETE = 3, // Delete record and keep walking
  23. ULC_DELETE_STOP = 4, // Delete record, then stop
  24. } UL_CACHE_PREDICATE, *PUL_CACHE_PREDICATE;
  25. //
  26. // THIS enum is primarily for debugging.
  27. // It tells you what precondition forced a cache miss.
  28. //
  29. typedef enum _URI_PRECONDITION
  30. {
  31. URI_PRE_OK, // OK to serve
  32. URI_PRE_DISABLED, // Cache disabled
  33. // request conditions
  34. URI_PRE_ENTITY_BODY = 10, // There was an entity body
  35. URI_PRE_VERB, // Verb wasn't GET
  36. URI_PRE_PROTOCOL, // Wasn't 1.x request
  37. URI_PRE_TRANSLATE, // Translate: f
  38. URI_PRE_AUTHORIZATION, // Auth headers present
  39. URI_PRE_CONDITIONAL, // Unhandled conditionals present
  40. URI_PRE_ACCEPT, // Accept: mismatch
  41. URI_PRE_OTHER_HEADER, // Other evil header present
  42. URI_PRE_EXPECTATION_FAILED, // Expect: 100-continue
  43. // response conditions
  44. URI_PRE_REQUEST = 50, // Problem with the request
  45. URI_PRE_POLICY, // Policy was wrong
  46. URI_PRE_SIZE, // Response too big
  47. URI_PRE_NOMEMORY, // No space in cache
  48. URI_PRE_FRAGMENT, // Didn't get whole response
  49. URI_PRE_BOGUS // Bogus response
  50. } URI_PRECONDITION;
  51. //
  52. // 100-continue token for Expect: header
  53. //
  54. #define HTTP_100_CONTINUE "100-continue"
  55. #define HTTP_CONTINUE_LENGTH STRLEN_LIT(HTTP_100_CONTINUE)
  56. BOOLEAN
  57. UlpCheckTableSpace(
  58. IN ULONGLONG EntrySize
  59. );
  60. BOOLEAN
  61. UlpCheckSpaceAndAddEntryStats(
  62. PUL_URI_CACHE_ENTRY pUriCacheEntry
  63. );
  64. VOID
  65. UlpRemoveEntryStats(
  66. PUL_URI_CACHE_ENTRY pUriCacheEntry
  67. );
  68. VOID
  69. UlpAddZombie(
  70. PUL_URI_CACHE_ENTRY pUriCacheEntry,
  71. BOOLEAN fTakeZombieLock
  72. );
  73. VOID
  74. UlpClearZombieList(
  75. VOID
  76. );
  77. //
  78. // Passed down to the filter callback functions by UlpFilteredFlushUriCache
  79. //
  80. typedef struct _URI_FILTER_CONTEXT
  81. {
  82. UL_WORK_ITEM WorkItem; // for UlQueueWorkItem
  83. ULONG Signature; // URI_FILTER_CONTEXT_POOL_TAG
  84. ULONG ZombieCount; // for statistics
  85. LIST_ENTRY ZombieListHead; // UL_URI_CACHE_ENTRYs to be zombified
  86. PVOID pCallerContext; // context passed down by caller
  87. URI_KEY UriKey; // For recursive uri flushes.
  88. LARGE_INTEGER Now; // For checking Expire time
  89. } URI_FILTER_CONTEXT, *PURI_FILTER_CONTEXT;
  90. #define IS_VALID_FILTER_CONTEXT(context) \
  91. HAS_VALID_SIGNATURE(context, URI_FILTER_CONTEXT_POOL_TAG)
  92. // filter function pointer
  93. typedef
  94. UL_CACHE_PREDICATE
  95. (*PUL_URI_FILTER)(
  96. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  97. IN PVOID pvUriFilterContext
  98. );
  99. VOID
  100. UlpFilteredFlushUriCache(
  101. IN PUL_URI_FILTER pFilterRoutine,
  102. IN PVOID pCallerContext,
  103. IN PWSTR pUri,
  104. IN ULONG Length
  105. );
  106. VOID
  107. UlpFilteredFlushUriCacheInline(
  108. IN PUL_URI_FILTER pFilterRoutine,
  109. IN PVOID pCallerContext,
  110. IN PWSTR pUri,
  111. IN ULONG Length
  112. );
  113. VOID
  114. UlpFilteredFlushUriCacheWorker(
  115. IN PUL_URI_FILTER pFilterRoutine,
  116. IN PVOID pCallerContext,
  117. IN PWSTR pUri,
  118. IN ULONG Length,
  119. IN BOOLEAN InlineFlush
  120. );
  121. UL_CACHE_PREDICATE
  122. UlpFlushFilterAll(
  123. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  124. IN PVOID pContext
  125. );
  126. UL_CACHE_PREDICATE
  127. UlpFlushFilterProcess(
  128. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  129. IN PVOID pContext
  130. );
  131. UL_CACHE_PREDICATE
  132. UlpFlushFilterUriRecursive(
  133. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  134. IN PVOID pContext
  135. );
  136. VOID
  137. UlpFlushUri(
  138. IN PWSTR pUri,
  139. IN ULONG Length,
  140. PUL_APP_POOL_PROCESS pProcess
  141. );
  142. UL_CACHE_PREDICATE
  143. UlpZombifyEntry(
  144. BOOLEAN MustZombify,
  145. BOOLEAN MustMarkEntry,
  146. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  147. IN PURI_FILTER_CONTEXT pUriFilterContext
  148. );
  149. VOID
  150. UlpZombifyList(
  151. IN PUL_WORK_ITEM pWorkItem
  152. );
  153. //
  154. // Cache entry stuff
  155. //
  156. // CODEWORK: make this function (and put in cache.h header)
  157. PUL_URI_CACHE_ENTRY
  158. UlAllocateUriCacheEntry(
  159. // much stuff
  160. );
  161. VOID
  162. UlpDestroyUriCacheEntry(
  163. PUL_URI_CACHE_ENTRY pUriCacheEntry
  164. );
  165. //
  166. // Scavenger stuff
  167. //
  168. UL_CACHE_PREDICATE
  169. UlpFlushFilterPeriodicScavenger(
  170. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  171. IN PVOID pvUriFilterContext
  172. );
  173. //
  174. // Low Memory Handling
  175. //
  176. // Used to pass parameters from UlTrimCache to UlpFlushFilterTrimCache
  177. typedef struct _UL_CACHE_TRIM_FILTER_CONTEXT {
  178. LONG_PTR Pages;
  179. LONG Age;
  180. } UL_CACHE_TRIM_FILTER_CONTEXT, *PUL_CACHE_TRIM_FILTER_CONTEXT;
  181. UL_CACHE_PREDICATE
  182. UlpFlushFilterTrimCache(
  183. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  184. IN PVOID pUriFilterContext
  185. );
  186. UL_CACHE_PREDICATE
  187. UlpFlushFilterIncScavengerTicks(
  188. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  189. IN PVOID pUriFilterContext
  190. );
  191. //
  192. // Fragment cache.
  193. //
  194. NTSTATUS
  195. UlpCreateFragmentCacheEntry(
  196. IN PUL_APP_POOL_PROCESS pProcess,
  197. IN PWSTR pFragmentName,
  198. IN ULONG FragmentNameLength,
  199. IN ULONG Length,
  200. IN PHTTP_CACHE_POLICY pCachePolicy,
  201. OUT PUL_URI_CACHE_ENTRY *pCacheEntry
  202. );
  203. //
  204. // Other cache routines.
  205. //
  206. BOOLEAN
  207. UlpQueryTranslateHeader(
  208. IN PUL_INTERNAL_REQUEST pRequest
  209. );
  210. BOOLEAN
  211. UlpQueryExpectHeader(
  212. IN PUL_INTERNAL_REQUEST pRequest
  213. );
  214. UL_CACHE_PREDICATE
  215. UlpFlushFilterClearCentralizedLogged(
  216. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  217. IN PVOID pContext
  218. );
  219. #endif // _CACHEP_H_