Mercurial > hg > nginx
diff src/http/modules/ngx_http_static_handler.c @ 197:0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 27 Nov 2003 07:45:22 +0000 |
parents | 8dee38ea9117 |
children | a65b630b3a66 |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_static_handler.c Wed Nov 26 15:42:18 2003 +0000 +++ b/src/http/modules/ngx_http_static_handler.c Thu Nov 27 07:45:22 2003 +0000 @@ -39,12 +39,13 @@ }; -int ngx_http_static_translate_handler(ngx_http_request_t *r) +ngx_int_t ngx_http_static_translate_handler(ngx_http_request_t *r) { - int rc, level; + ngx_int_t rc, level; + uint32_t crc; char *location, *last; ngx_err_t err; - ngx_http_cache_ctx_t ctx; + ngx_http_cache_t *cache; ngx_http_cache_conf_t *ccf; ngx_http_core_loc_conf_t *clcf; @@ -87,23 +88,16 @@ ngx_log_debug(r->connection->log, "HTTP filename: '%s'" _ r->file.name.data); - - /* STUB */ - ccf = NULL; - ctx.key.len = 0; - -#if 0 ccf = ngx_http_get_module_loc_conf(r, ngx_http_cache_module); if (ccf->open_files) { - ctx->hash = ccf->open_files; - ctx->key = r->file.name; + cache = ngx_http_cache_get(ccf->open_files, &r->file.name, &crc); - cache = ngx_http_cache_get_data(r, ctx); +ngx_log_debug(r->connection->log, "cache get: %x" _ cache); if (cache && ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) - || ccf->hash->life_time >= ngx_time() - cache->updated)) + || ccf->open_files->check_time >= ngx_time() - cache->updated)) { cache->refs++; r->file.fd = cache->fd; @@ -117,8 +111,6 @@ cache = NULL; } -#endif - #if (WIN9X) if (ngx_win32_version < NGX_WIN_NT) { @@ -215,6 +207,23 @@ r->file.info_valid = 1; } + if (ccf->open_files) { + if (cache == NULL) { + cache = ngx_http_cache_alloc(ccf->open_files, &r->file.name, crc, + r->connection->log); + } + +ngx_log_debug(r->connection->log, "cache alloc: %x" _ cache); + + if (cache) { + cache->fd = r->file.fd; + cache->data.size = ngx_file_size(&r->file.info); + cache->accessed = ngx_time(); + cache->last_modified = ngx_file_mtime(&r->file.info); + cache->updated = ngx_time(); + } + } + if (ngx_is_dir(&r->file.info)) { ngx_log_debug(r->connection->log, "HTTP DIR: '%s'" _ r->file.name.data);