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.

275 lines
5.8 KiB

  1. /*++
  2. Copyright (c) 1998-2001 Microsoft Corporation
  3. Module Name:
  4. cache.h
  5. Abstract:
  6. The public definition of response cache interfaces.
  7. Author:
  8. Michael Courage (mcourage) 17-May-1999
  9. Revision History:
  10. --*/
  11. #ifndef _CACHE_H_
  12. #define _CACHE_H_
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif // __cplusplus
  16. //
  17. // Forwards
  18. //
  19. typedef struct _UL_INTERNAL_RESPONSE *PUL_INTERNAL_RESPONSE;
  20. typedef struct _UL_INTERNAL_DATA_CHUNK *PUL_INTERNAL_DATA_CHUNK;
  21. //
  22. // Cache configuration
  23. //
  24. typedef struct _UL_URI_CACHE_CONFIG {
  25. BOOLEAN EnableCache;
  26. ULONG MaxCacheUriCount;
  27. ULONG MaxCacheMegabyteCount;
  28. ULONG ScavengerPeriod;
  29. ULONG MaxUriBytes;
  30. LONG HashTableBits;
  31. } UL_URI_CACHE_CONFIG, *PUL_URI_CACHE_CONFIG;
  32. extern UL_URI_CACHE_CONFIG g_UriCacheConfig;
  33. //
  34. // Structure of an HTTP cache table entry.
  35. //
  36. typedef struct _URI_KEY
  37. {
  38. ULONG Hash;
  39. ULONG Length; // #bytes in pUri, excluding L'\0'
  40. PWSTR pUri;
  41. } URI_KEY, *PURI_KEY;
  42. //
  43. // Structure for holding the split-up content type. Assumes that types and
  44. // subtypes will never be longer than MAX_TYPE_LEN.
  45. //
  46. #define MAX_TYPE_LENGTH 32
  47. #define MAX_SUBTYPE_LENGTH 64
  48. typedef struct _UL_CONTENT_TYPE
  49. {
  50. ULONG TypeLen;
  51. UCHAR Type[MAX_TYPE_LENGTH];
  52. ULONG SubTypeLen;
  53. UCHAR SubType[MAX_SUBTYPE_LENGTH];
  54. } UL_CONTENT_TYPE, *PUL_CONTENT_TYPE;
  55. #define IS_VALID_URI_CACHE_ENTRY(pEntry) \
  56. ((pEntry) != NULL && UL_URI_CACHE_ENTRY_POOL_TAG == (pEntry)->Signature)
  57. typedef struct _UL_URI_CACHE_ENTRY // CacheEntry
  58. {
  59. //
  60. // PagedPool
  61. //
  62. ULONG Signature; // UL_URI_CACHE_ENTRY_POOL_TAG
  63. LONG ReferenceCount;
  64. //
  65. // cache info
  66. //
  67. SINGLE_LIST_ENTRY BucketEntry;
  68. URI_KEY UriKey;
  69. ULONG HitCount;
  70. LIST_ENTRY ZombieListEntry;
  71. BOOLEAN Zombie;
  72. BOOLEAN ZombieAddReffed;
  73. BOOLEAN Cached;
  74. BOOLEAN ContentLengthSpecified; // hack
  75. USHORT StatusCode;
  76. HTTP_VERB Verb;
  77. ULONG ScavengerTicks;
  78. HTTP_CACHE_POLICY CachePolicy;
  79. LARGE_INTEGER ExpirationTime;
  80. //
  81. // System time of Date that went out on original response
  82. //
  83. LARGE_INTEGER CreationTime;
  84. //
  85. // ETag of original response
  86. //
  87. ULONG ETagLength; // Including NULL
  88. PUCHAR pETag;
  89. //
  90. // Content-Type of original response
  91. //
  92. UL_CONTENT_TYPE ContentType;
  93. //
  94. // config and process data for invalidation
  95. //
  96. UL_URL_CONFIG_GROUP_INFO ConfigInfo;
  97. PUL_APP_POOL_PROCESS pProcess;
  98. //
  99. // Response data
  100. //
  101. ULONG HeaderLength;
  102. ULONG ContentLength;
  103. PMDL pResponseMdl; // including content + header
  104. BOOLEAN LongTermCacheable;
  105. //
  106. // Logging Information
  107. //
  108. BOOLEAN LoggingEnabled;
  109. USHORT UsedOffset1;
  110. USHORT UsedOffset2;
  111. ULONG MaxLength;
  112. ULONG LogDataLength;
  113. PUCHAR pLogData;
  114. // WSTR Uri[];
  115. // UCHAR ETag[];
  116. // UCHAR LogData[];
  117. } UL_URI_CACHE_ENTRY, *PUL_URI_CACHE_ENTRY;
  118. //
  119. // public functions
  120. //
  121. NTSTATUS
  122. UlInitializeUriCache(
  123. PUL_CONFIG pConfig
  124. );
  125. VOID
  126. UlTerminateUriCache(
  127. VOID
  128. );
  129. VOID
  130. UlInitCacheEntry(
  131. PUL_URI_CACHE_ENTRY pUriCacheEntry,
  132. ULONG Hash,
  133. ULONG Length,
  134. PCWSTR pUrl
  135. );
  136. VOID
  137. UlAddCacheEntry(
  138. PUL_URI_CACHE_ENTRY pUriCacheEntry
  139. );
  140. PUL_URI_CACHE_ENTRY
  141. UlCheckoutUriCacheEntry(
  142. PUL_INTERNAL_REQUEST pRequest
  143. );
  144. VOID
  145. UlCheckinUriCacheEntry(
  146. PUL_URI_CACHE_ENTRY pUriCacheEntry
  147. );
  148. VOID
  149. UlFlushCache(
  150. VOID
  151. );
  152. VOID
  153. UlFlushCacheByProcess(
  154. PUL_APP_POOL_PROCESS pProcess
  155. );
  156. VOID
  157. UlFlushCacheByUri(
  158. IN PWSTR pUri,
  159. IN ULONG Length,
  160. IN ULONG Flags,
  161. PUL_APP_POOL_PROCESS pProcess
  162. );
  163. //
  164. // cachability test functions
  165. //
  166. BOOLEAN
  167. UlCheckCachePreconditions(
  168. PUL_INTERNAL_REQUEST pRequest,
  169. PUL_HTTP_CONNECTION pHttpConn
  170. );
  171. BOOLEAN
  172. UlCheckCacheResponseConditions(
  173. PUL_INTERNAL_REQUEST pRequest,
  174. PUL_INTERNAL_RESPONSE pResponse,
  175. ULONG Flags,
  176. HTTP_CACHE_POLICY CachePolicy
  177. );
  178. // reference counting
  179. LONG
  180. UlAddRefUriCacheEntry(
  181. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  182. IN REFTRACE_ACTION Action
  183. REFERENCE_DEBUG_FORMAL_PARAMS
  184. );
  185. LONG
  186. UlReleaseUriCacheEntry(
  187. IN PUL_URI_CACHE_ENTRY pUriCacheEntry,
  188. IN REFTRACE_ACTION Action
  189. REFERENCE_DEBUG_FORMAL_PARAMS
  190. );
  191. #define REFERENCE_URI_CACHE_ENTRY( pEntry, Action ) \
  192. UlAddRefUriCacheEntry( \
  193. (pEntry), \
  194. (REF_ACTION_##Action##_URI_ENTRY) \
  195. REFERENCE_DEBUG_ACTUAL_PARAMS \
  196. )
  197. #define DEREFERENCE_URI_CACHE_ENTRY( pEntry, Action ) \
  198. UlReleaseUriCacheEntry( \
  199. (pEntry), \
  200. (REF_ACTION_##Action##_URI_ENTRY) \
  201. REFERENCE_DEBUG_ACTUAL_PARAMS \
  202. )
  203. #ifdef __cplusplus
  204. }; // extern "C"
  205. #endif // __cplusplus
  206. #endif // _CACHE_H_