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.

247 lines
5.4 KiB

  1. /*++
  2. Copyright (c) 1998-2001 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. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. //
  17. // constants
  18. //
  19. #define CACHE_ENTRY_AGE_THRESHOLD 1
  20. #define ZOMBIE_AGE_THRESHOLD 5
  21. //
  22. // Cache statistics
  23. //
  24. typedef struct _UL_URI_CACHE_STATS {
  25. ULONG UriCount; // entries in hash table
  26. ULONG UriCountMax; // high water mark
  27. ULONGLONG UriAddedTotal; // total entries ever added
  28. ULONGLONG ByteCount; // memory used for cache
  29. ULONGLONG ByteCountMax; // high water
  30. ULONG ZombieCount; // length of zombie list
  31. ULONG ZombieCountMax; // high water
  32. ULONG HitCount; // table lookup succeeded
  33. ULONG MissTableCount; // entry not in table
  34. ULONG MissPreconditionCount; // request not cacheable
  35. ULONG MissConfigCount; // config invalidated
  36. } UL_URI_CACHE_STATS, *PUL_URI_CACHE_STATS;
  37. enum ULC_RETCODE {
  38. ULC_SUCCESS = 0, // everything's okay
  39. ULC_KEY_EXISTS, // key already present for
  40. };
  41. enum UL_CACHE_PREDICATE {
  42. ULC_ABORT = 1, // Stop walking the table immediately
  43. ULC_NO_ACTION = 2, // No action, just keep walking
  44. ULC_PERFORM = 3, // Perform action and continue walking
  45. ULC_PERFORM_STOP = 4, // Perform action, then stop
  46. ULC_DELETE = 5, // Delete record and keep walking
  47. ULC_DELETE_STOP = 6, // Delete record, then stop
  48. };
  49. //
  50. // THIS enum is primarily for debugging.
  51. // It tells you what precondition forced a cache miss.
  52. //
  53. typedef enum _URI_PRECONDITION {
  54. URI_PRE_OK, // OK to serve
  55. URI_PRE_DISABLED, // Cache disabled
  56. // request conditions
  57. URI_PRE_ENTITY_BODY = 10, // There was an entity body
  58. URI_PRE_VERB, // Verb wasn't GET
  59. URI_PRE_PROTOCOL, // Wasn't 1.x request
  60. URI_PRE_TRANSLATE, // Translate: f
  61. URI_PRE_AUTHORIZATION, // Auth headers present
  62. URI_PRE_CONDITIONAL, // Unhandled conditionals present
  63. URI_PRE_ACCEPT, // Accept: mismatch
  64. URI_PRE_OTHER_HEADER, // Other evil header present
  65. // response conditions
  66. URI_PRE_REQUEST = 50, // Problem with the request
  67. URI_PRE_POLICY, // Policy was wrong
  68. URI_PRE_SIZE, // Response too big
  69. URI_PRE_NOMEMORY, // No space in cache
  70. URI_PRE_FRAGMENT, // Didn't get whole response
  71. URI_PRE_BOGUS // Bogus response
  72. } URI_PRECONDITION;
  73. BOOLEAN
  74. UlpCheckTableSpace(
  75. IN ULONGLONG EntrySize
  76. );
  77. BOOLEAN
  78. UlpCheckSpaceAndAddEntryStats(
  79. PUL_URI_CACHE_ENTRY pUriCacheEntry
  80. );
  81. VOID
  82. UlpRemoveEntryStats(
  83. PUL_URI_CACHE_ENTRY pUriCacheEntry
  84. );
  85. VOID
  86. UlpAddZombie(
  87. PUL_URI_CACHE_ENTRY pUriCacheEntry,
  88. BOOLEAN fTakeZombieLock
  89. );
  90. VOID
  91. UlpClearZombieList(
  92. VOID
  93. );
  94. // Passed down to the filter callback functions by UlpFilteredFlushUriCache
  95. typedef struct _URI_FILTER_CONTEXT
  96. {
  97. ULONG Signature; // URI_FILTER_CONTEXT_POOL_TAG
  98. UL_WORK_ITEM WorkItem; // for UlQueueWorkItem
  99. LIST_ENTRY ZombieListHead; // UL_URI_CACHE_ENTRYs to be zombified
  100. PVOID pCallerContext; // context passed down by caller
  101. ULONG ZombieCount; // for statistics
  102. } URI_FILTER_CONTEXT, *PURI_FILTER_CONTEXT;
  103. // filter function pointer
  104. typedef
  105. UL_CACHE_PREDICATE
  106. (*PUL_URI_FILTER)(
  107. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  108. IN PVOID pvUriFilterContext
  109. );
  110. VOID
  111. UlpFilteredFlushUriCache(
  112. IN PUL_URI_FILTER pFilterRoutine,
  113. IN PVOID pCallerContext
  114. );
  115. UL_CACHE_PREDICATE
  116. UlpFlushFilterAll(
  117. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  118. IN PVOID pContext
  119. );
  120. UL_CACHE_PREDICATE
  121. UlpFlushFilterProcess(
  122. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  123. IN PVOID pContext
  124. );
  125. VOID
  126. UlpFlushUri(
  127. IN PWSTR pUri,
  128. IN ULONG Length,
  129. PUL_APP_POOL_PROCESS pProcess
  130. );
  131. UL_CACHE_PREDICATE
  132. UlpZombifyEntry(
  133. BOOLEAN MustZombify,
  134. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  135. IN PURI_FILTER_CONTEXT pUriFilterContext
  136. );
  137. VOID
  138. UlpZombifyList(
  139. IN PUL_WORK_ITEM pWorkItem
  140. );
  141. //
  142. // Cache entry stuff
  143. //
  144. // CODEWORK: make this function (and put in cache.h header)
  145. PUL_URI_CACHE_ENTRY
  146. UlAllocateUriCacheEntry(
  147. // much stuff
  148. );
  149. VOID
  150. UlpDestroyUriCacheEntry(
  151. PUL_URI_CACHE_ENTRY pUriCacheEntry
  152. );
  153. //
  154. // Scavenger stuff
  155. //
  156. VOID
  157. UlpInitializeScavenger(
  158. VOID
  159. );
  160. VOID
  161. UlpTerminateScavenger(
  162. VOID
  163. );
  164. VOID
  165. UlpSetScavengerTimer(
  166. VOID
  167. );
  168. VOID
  169. UlpScavengerDpcRoutine(
  170. IN PKDPC Dpc,
  171. IN PVOID DeferredContext,
  172. IN PVOID SystemArgument1,
  173. IN PVOID SystemArgument2
  174. );
  175. VOID
  176. UlpScavenger(
  177. IN PUL_WORK_ITEM pWorkItem
  178. );
  179. UL_CACHE_PREDICATE
  180. UlpFlushFilterScavenger(
  181. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  182. IN PVOID pvUriFilterContext
  183. );
  184. //
  185. // Other cache routines.
  186. //
  187. BOOLEAN
  188. UlpQueryTranslateHeader(
  189. IN PUL_INTERNAL_REQUEST pRequest
  190. );
  191. #ifdef __cplusplus
  192. }; // extern "C"
  193. #endif
  194. #endif // _CACHEP_H_