aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_script.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2007-09-01 12:12:48 +0000
committerIgor Sysoev <igor@sysoev.ru>2007-09-01 12:12:48 +0000
commit140c7556a27050f5059e2edd9b038835ff6cd338 (patch)
treed176eeb05f2e7ea2222979e828e568d6de0cdcb2 /src/http/ngx_http_script.c
parentd92bee51ea4db438a79c075a45937d5789210ab2 (diff)
downloadnginx-140c7556a27050f5059e2edd9b038835ff6cd338.tar.gz
nginx-140c7556a27050f5059e2edd9b038835ff6cd338.zip
open_file_cache in HTTP
Diffstat (limited to 'src/http/ngx_http_script.c')
-rw-r--r--src/http/ngx_http_script.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c
index 945602178..78c42722e 100644
--- a/src/http/ngx_http_script.c
+++ b/src/http/ngx_http_script.c
@@ -952,8 +952,10 @@ ngx_http_script_not_equal_code(ngx_http_script_engine_t *e)
void
ngx_http_script_file_code(ngx_http_script_engine_t *e)
{
- ngx_err_t err;
- ngx_file_info_t fi;
+ ngx_str_t path;
+ ngx_http_request_t *r;
+ ngx_open_file_info_t of;
+ ngx_http_core_loc_conf_t *clcf;
ngx_http_variable_value_t *value;
ngx_http_script_file_code_t *code;
@@ -962,14 +964,25 @@ ngx_http_script_file_code(ngx_http_script_engine_t *e)
code = (ngx_http_script_file_code_t *) e->ip;
e->ip += sizeof(ngx_http_script_file_code_t);
- ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
- "http script file op %p", code->op);
+ path.len = value->len - 1;
+ path.data = value->data;
+
+ r = e->request;
+
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http script file op %p \"%V\"", code->op, &path);
+
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
- if (ngx_file_info(value->data, &fi) == -1) {
- err = ngx_errno;
+ of.test_dir = 0;
+ of.retest = clcf->open_file_cache_retest;
+ of.errors = clcf->open_file_cache_errors;
- if (err != NGX_ENOENT && err != NGX_ENOTDIR) {
- ngx_log_error(NGX_LOG_CRIT, e->request->connection->log, err,
+ if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
+ == NGX_ERROR)
+ {
+ if (of.err != NGX_ENOENT && of.err != NGX_ENOTDIR) {
+ ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err,
ngx_file_info_n " \"%s\" failed", value->data);
}
@@ -993,69 +1006,57 @@ ngx_http_script_file_code(ngx_http_script_engine_t *e)
switch (code->op) {
case ngx_http_script_file_plain:
- if (ngx_is_file(&fi)) {
+ if (of.is_file) {
goto true;
}
goto false;
case ngx_http_script_file_not_plain:
- if (ngx_is_file(&fi)) {
+ if (of.is_file) {
goto false;
}
goto true;
case ngx_http_script_file_dir:
- if (ngx_is_dir(&fi)) {
+ if (of.is_dir) {
goto true;
}
goto false;
case ngx_http_script_file_not_dir:
- if (ngx_is_dir(&fi)) {
+ if (of.is_dir) {
goto false;
}
goto true;
case ngx_http_script_file_exists:
- if (ngx_is_file(&fi) || ngx_is_dir(&fi) || ngx_is_link(&fi)) {
+ if (of.is_file || of.is_dir || of.is_link) {
goto true;
}
goto false;
case ngx_http_script_file_not_exists:
- if (ngx_is_file(&fi) || ngx_is_dir(&fi) || ngx_is_link(&fi)) {
+ if (of.is_file || of.is_dir || of.is_link) {
goto false;
}
goto true;
-#if (NGX_WIN32)
-
- case ngx_http_script_file_exec:
- goto false;
-
- case ngx_http_script_file_not_exec:
- goto true;
-
-#else
-
case ngx_http_script_file_exec:
- if (ngx_is_exec(&fi)) {
+ if (of.is_exec) {
goto true;
}
goto false;
case ngx_http_script_file_not_exec:
- if (ngx_is_exec(&fi)) {
+ if (of.is_exec) {
goto false;
}
goto true;
-
-#endif
}
false:
- ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http script file op false");
*value = ngx_http_variable_null_value;