Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-12-21 15:30:30 +0300
committerIgor Sysoev <igor@sysoev.ru>2004-12-21 15:30:30 +0300
commitb1dfe478a03ad6919f174812951f6a2bec8befae (patch)
treed8802484f8dbf5309b17a95b5fc9749627720a53 /src/http/ngx_http_cache.c
parent5275a8b3ac534ff36973801ec2aa6ce1214d7cc9 (diff)
nginx-0.1.13-RELEASE importrelease-0.1.13
*) Feature: the server_names_hash and server_names_hash_threshold directives. *) Bugfix: the *.domain.tld names in the "server_name" directive did not work. *) Bugfix: the %request_length log parameter logged the incorrect length.
Diffstat (limited to 'src/http/ngx_http_cache.c')
-rw-r--r--src/http/ngx_http_cache.c98
1 files changed, 97 insertions, 1 deletions
diff --git a/src/http/ngx_http_cache.c b/src/http/ngx_http_cache.c
index abdeae989..8471459af 100644
--- a/src/http/ngx_http_cache.c
+++ b/src/http/ngx_http_cache.c
@@ -9,6 +9,7 @@
#include <ngx_http.h>
+#if 0
static ngx_http_module_t ngx_http_cache_module_ctx = {
NULL, /* pre conf */
@@ -30,9 +31,101 @@ ngx_module_t ngx_http_cache_module = {
NULL, /* module directives */
NGX_HTTP_MODULE, /* module type */
NULL, /* init module */
- NULL /* init child */
+ NULL /* init process */
};
+#endif
+
+
+static ngx_int_t ngx_http_cache_create(ngx_http_request_t *r)
+{
+ ngx_str_t *key;
+
+ if (!(r->cache = ngx_pcalloc(r->pool, sizeof(ngx_http_cache_t)))) {
+ return NGX_ERROR;
+ }
+
+ if (ngx_array_init(&r->cache->key, r->pool, 5, sizeof(ngx_str_t))
+ == NGX_ERROR)
+ {
+ return NGX_ERROR;
+ }
+
+ /* preallocate the primary key */
+
+ if (!(key = ngx_array_push(&r->cache->key))) {
+ return NGX_ERROR;
+ }
+
+ key->len = 0;
+ key->data = NULL;
+
+ /*
+ * we use offsetof() because sizeof() pads the struct size to the int size
+ */
+
+ r->cache->header_size = offsetof(ngx_http_cache_header_t, key);
+
+ r->cache->log = r->connection->log;
+ r->cache->file.log = r->connection->log;
+
+ return NGX_OK;
+}
+
+
+ngx_int_t ngx_http_cache_get(ngx_http_request_t *r, ngx_http_cache_ctx_t *ctx)
+{
+ ngx_str_t *key;
+ ngx_http_cache_t *c;
+
+ if (r->cache == NULL) {
+ if (ngx_http_cache_create(r) == NGX_ERROR) {
+ return NGX_ABORT;
+ }
+ }
+
+ c = r->cache;
+ key = c->key.elts;
+
+ if (ctx->primary) {
+ key[0] = ctx->key;
+ c->header_size += ctx->key.len;
+ c->key_len += ctx->key.len;
+ c->buf = ctx->buf;
+
+ } else {
+ if (key[0].len == 0) {
+ key[0] = r->uri;
+ c->header_size += r->uri.len;
+ c->key_len += ctx->key.len;
+ }
+
+ if (!(key = ngx_array_push(&r->cache->key))) {
+ return NGX_ABORT;
+ }
+
+ c->header_size += ctx->key.len;
+ c->key_len += ctx->key.len;
+ }
+
+#if 0
+
+ if (ctx->memory) {
+ ngx_http_memory_cache_get(r, ctx);
+ }
+
+#endif
+
+ if (ctx->file) {
+ return ngx_http_file_cache_get(r, ctx);
+ }
+
+ return NGX_DECLINED;
+}
+
+
+#if 0
+
ngx_http_cache_t *ngx_http_cache_get(ngx_http_cache_hash_t *hash,
ngx_http_cleanup_t *cleanup,
@@ -478,3 +571,6 @@ char *ngx_http_set_cache_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_OK;
}
+
+
+#endif