Mercurial > hg > nginx
diff src/http/ngx_http_cache.c @ 99:a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 02 Jun 2003 15:24:30 +0000 |
parents | 70d2345a903f |
children | 00bee6e7b485 |
line wrap: on
line diff
--- 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_ha 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_ha 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; +}