summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http_cache.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-06-02 15:24:30 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-06-02 15:24:30 +0000
commit7578ec9df43bbb31db5291f1b76359d10900a679 (patch)
tree87d7b3cb729c0e07b21d52737fd76e12a0c17d72 /src/http/ngx_http_cache.c
parentaa3436c04c222d57498bfa34c9fdec50f07fd08d (diff)
downloadnginx-7578ec9df43bbb31db5291f1b76359d10900a679.tar.gz
nginx-7578ec9df43bbb31db5291f1b76359d10900a679.tar.bz2
nginx-0.0.1-2003-06-02-19:24:30 import
Diffstat (limited to '')
-rw-r--r--src/http/ngx_http_cache.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/http/ngx_http_cache.c b/src/http/ngx_http_cache.c
index f9e36f597..0c563206c 100644
--- a/src/http/ngx_http_cache.c
+++ b/src/http/ngx_http_cache.c
@@ -1,5 +1,12 @@
+/*
+ * small file in malloc()ed memory, mmap()ed file, file descriptor only,
+ * file access time only (to estimate can pages pages still be in memory),
+ * translated URI (ngx_http_index_hanlder),
+ * compiled script (ngx_http_ssi_filter).
+ */
+
#define NGX_HTTP_CACHE_ENTRY_DELETED 0x00000001
#define NGX_HTTP_CACHE_ENTRY_MMAPED 0x00000002
@@ -7,6 +14,9 @@
/* "/" -> "/index.html" in ngx_http_index_handler */
#define NGX_HTTP_CACHE_ENTRY_URI 0x00000004
+/* complied script */
+#define NGX_HTTP_CACHE_ENTRY_SCRIPT 0x00000008
+
#define NGX_HTTP_CACHE_FILTER_FLAGS 0xFFFF0000
@@ -42,7 +52,7 @@ int ngx_http_cache_get(ngx_http_cache_hash_t *cache_hash,
int hi;
ngx_http_cache_hash_entry_t *entry;
- h->crc = ngx_crc32(uri->data, uri->len);
+ h->crc = ngx_crc(uri->data, uri->len);
hi = h->crc % cache_hash->size;
entry = cache_hash[hi].elts;
@@ -61,3 +71,23 @@ int ngx_http_cache_get(ngx_http_cache_hash_t *cache_hash,
return NGX_ERROR;
}
+
+
+/* 32-bit crc16 */
+
+int ngx_crc(char *data, size_t len)
+{
+ u_int32_t sum;
+
+ for (sum = 0; len; len--) {
+ /*
+ * gcc 2.95.2 x86 compiles that operator into the single rol opcode.
+ * msvc 6.0sp2 compiles it into four opcodes.
+ */
+ sum = sum >> 1 | sum << 31;
+
+ sum += *data++;
+ }
+
+ return sum;
+}