Mercurial > hg > nginx-mail
comparison src/http/ngx_http_script.c @ 332:3a91bfeffaba NGINX_0_6_10
nginx 0.6.10
*) Feature: the "open_file_cache", "open_file_cache_retest", and
"open_file_cache_errors" directives.
*) Bugfix: socket leak; bug appeared in 0.6.7.
*) Bugfix: a charset set by the "charset" directive was not appended to
the "Content-Type" header set by $r->send_http_header().
*) Bugfix: a segmentation fault might occur in worker process if
/dev/poll method was used.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 03 Sep 2007 00:00:00 +0400 |
parents | 390b8f8309d6 |
children | 10cc350ed8a1 |
comparison
equal
deleted
inserted
replaced
331:b69d5e83bf82 | 332:3a91bfeffaba |
---|---|
950 | 950 |
951 | 951 |
952 void | 952 void |
953 ngx_http_script_file_code(ngx_http_script_engine_t *e) | 953 ngx_http_script_file_code(ngx_http_script_engine_t *e) |
954 { | 954 { |
955 ngx_err_t err; | 955 ngx_str_t path; |
956 ngx_file_info_t fi; | 956 ngx_http_request_t *r; |
957 ngx_open_file_info_t of; | |
958 ngx_http_core_loc_conf_t *clcf; | |
957 ngx_http_variable_value_t *value; | 959 ngx_http_variable_value_t *value; |
958 ngx_http_script_file_code_t *code; | 960 ngx_http_script_file_code_t *code; |
959 | 961 |
960 value = e->sp - 1; | 962 value = e->sp - 1; |
961 | 963 |
962 code = (ngx_http_script_file_code_t *) e->ip; | 964 code = (ngx_http_script_file_code_t *) e->ip; |
963 e->ip += sizeof(ngx_http_script_file_code_t); | 965 e->ip += sizeof(ngx_http_script_file_code_t); |
964 | 966 |
965 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | 967 path.len = value->len - 1; |
966 "http script file op %p", code->op); | 968 path.data = value->data; |
967 | 969 |
968 if (ngx_file_info(value->data, &fi) == -1) { | 970 r = e->request; |
969 err = ngx_errno; | 971 |
970 | 972 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
971 if (err != NGX_ENOENT && err != NGX_ENOTDIR) { | 973 "http script file op %p \"%V\"", code->op, &path); |
972 ngx_log_error(NGX_LOG_CRIT, e->request->connection->log, err, | 974 |
975 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
976 | |
977 of.test_dir = 0; | |
978 of.retest = clcf->open_file_cache_retest; | |
979 of.errors = clcf->open_file_cache_errors; | |
980 of.events = clcf->open_file_cache_events; | |
981 | |
982 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool) | |
983 == NGX_ERROR) | |
984 { | |
985 if (of.err != NGX_ENOENT && of.err != NGX_ENOTDIR) { | |
986 ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err, | |
973 ngx_file_info_n " \"%s\" failed", value->data); | 987 ngx_file_info_n " \"%s\" failed", value->data); |
974 } | 988 } |
975 | 989 |
976 switch (code->op) { | 990 switch (code->op) { |
977 | 991 |
991 goto false; | 1005 goto false; |
992 } | 1006 } |
993 | 1007 |
994 switch (code->op) { | 1008 switch (code->op) { |
995 case ngx_http_script_file_plain: | 1009 case ngx_http_script_file_plain: |
996 if (ngx_is_file(&fi)) { | 1010 if (of.is_file) { |
997 goto true; | 1011 goto true; |
998 } | 1012 } |
999 goto false; | 1013 goto false; |
1000 | 1014 |
1001 case ngx_http_script_file_not_plain: | 1015 case ngx_http_script_file_not_plain: |
1002 if (ngx_is_file(&fi)) { | 1016 if (of.is_file) { |
1003 goto false; | 1017 goto false; |
1004 } | 1018 } |
1005 goto true; | 1019 goto true; |
1006 | 1020 |
1007 case ngx_http_script_file_dir: | 1021 case ngx_http_script_file_dir: |
1008 if (ngx_is_dir(&fi)) { | 1022 if (of.is_dir) { |
1009 goto true; | 1023 goto true; |
1010 } | 1024 } |
1011 goto false; | 1025 goto false; |
1012 | 1026 |
1013 case ngx_http_script_file_not_dir: | 1027 case ngx_http_script_file_not_dir: |
1014 if (ngx_is_dir(&fi)) { | 1028 if (of.is_dir) { |
1015 goto false; | 1029 goto false; |
1016 } | 1030 } |
1017 goto true; | 1031 goto true; |
1018 | 1032 |
1019 case ngx_http_script_file_exists: | 1033 case ngx_http_script_file_exists: |
1020 if (ngx_is_file(&fi) || ngx_is_dir(&fi) || ngx_is_link(&fi)) { | 1034 if (of.is_file || of.is_dir || of.is_link) { |
1021 goto true; | 1035 goto true; |
1022 } | 1036 } |
1023 goto false; | 1037 goto false; |
1024 | 1038 |
1025 case ngx_http_script_file_not_exists: | 1039 case ngx_http_script_file_not_exists: |
1026 if (ngx_is_file(&fi) || ngx_is_dir(&fi) || ngx_is_link(&fi)) { | 1040 if (of.is_file || of.is_dir || of.is_link) { |
1027 goto false; | 1041 goto false; |
1028 } | 1042 } |
1029 goto true; | 1043 goto true; |
1030 | 1044 |
1031 #if (NGX_WIN32) | |
1032 | |
1033 case ngx_http_script_file_exec: | 1045 case ngx_http_script_file_exec: |
1046 if (of.is_exec) { | |
1047 goto true; | |
1048 } | |
1034 goto false; | 1049 goto false; |
1035 | 1050 |
1036 case ngx_http_script_file_not_exec: | 1051 case ngx_http_script_file_not_exec: |
1052 if (of.is_exec) { | |
1053 goto false; | |
1054 } | |
1037 goto true; | 1055 goto true; |
1038 | |
1039 #else | |
1040 | |
1041 case ngx_http_script_file_exec: | |
1042 if (ngx_is_exec(&fi)) { | |
1043 goto true; | |
1044 } | |
1045 goto false; | |
1046 | |
1047 case ngx_http_script_file_not_exec: | |
1048 if (ngx_is_exec(&fi)) { | |
1049 goto false; | |
1050 } | |
1051 goto true; | |
1052 | |
1053 #endif | |
1054 } | 1056 } |
1055 | 1057 |
1056 false: | 1058 false: |
1057 | 1059 |
1058 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | 1060 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1059 "http script file op false"); | 1061 "http script file op false"); |
1060 | 1062 |
1061 *value = ngx_http_variable_null_value; | 1063 *value = ngx_http_variable_null_value; |
1062 return; | 1064 return; |
1063 | 1065 |