comparison src/http/modules/ngx_http_index_module.c @ 482:392c16f2d858 NGINX_0_7_53

nginx 0.7.53 *) Change: now a log set by --error-log-path is created from the very start-up. *) Feature: now the start up errors and warnings are outputted to an error_log and stderr. *) Feature: the empty --prefix= configure parameter forces nginx to use a directory where it was run as prefix. *) Feature: the -p switch. *) Feature: the -s switch on Unix platforms. *) Feature: the -? and -h switches. Thanks to Jerome Loyet. *) Feature: now switches may be set in condensed form. *) Bugfix: nginx/Windows did not work if configuration file was given by the -c switch. *) Bugfix: temporary files might be not removed if the "proxy_store", "fastcgi_store", "proxy_cache", or "fastcgi_cache" were used. Thanks to Maxim Dounin. *) Bugfix: an incorrect value was passed to mail proxy authentication server in "Auth-Method" header line; the bug had appeared in 0.7.34. Thanks to Simon Lecaille. *) Bugfix: system error text descriptions were not logged on Linux; the bug had appeared in 0.7.45. *) Bugfix: the "fastcgi_cache_min_uses" directive did not work. Thanks to Andrew Vorobyoff.
author Igor Sysoev <http://sysoev.ru>
date Mon, 27 Apr 2009 00:00:00 +0400
parents 549994537f15
children f39b9e29530d
comparison
equal deleted inserted replaced
481:0c98173187ac 482:392c16f2d858
81 NGX_MODULE_V1_PADDING 81 NGX_MODULE_V1_PADDING
82 }; 82 };
83 83
84 84
85 /* 85 /*
86 * Try to open the first index file before the test of the directory existence 86 * Try to open/test the first index file before the test of directory
87 * because the valid requests should be many more than invalid ones. 87 * existence because valid requests should be much more than invalid ones.
88 * If open() would fail, then stat() should be more quickly because some data 88 * If the file open()/stat() would fail, then the directory stat() should
89 * is already cached in the kernel. 89 * be more quickly because some data is already cached in the kernel.
90 * Besides, Win32 has ERROR_PATH_NOT_FOUND (NGX_ENOTDIR). 90 * Besides, Win32 may return ERROR_PATH_NOT_FOUND (NGX_ENOTDIR) at once.
91 * Unix has ENOTDIR error, although it less helpfull - it points only 91 * Unix has ENOTDIR error, however, it's less helpful than Win32's one:
92 * that path contains the usual file in place of the directory. 92 * it only indicates that path contains an usual file in place of directory.
93 */ 93 */
94 94
95 static ngx_int_t 95 static ngx_int_t
96 ngx_http_index_handler(ngx_http_request_t *r) 96 ngx_http_index_handler(ngx_http_request_t *r)
97 { 97 {
206 ngx_memzero(&of, sizeof(ngx_open_file_info_t)); 206 ngx_memzero(&of, sizeof(ngx_open_file_info_t));
207 207
208 of.directio = clcf->directio; 208 of.directio = clcf->directio;
209 of.valid = clcf->open_file_cache_valid; 209 of.valid = clcf->open_file_cache_valid;
210 of.min_uses = clcf->open_file_cache_min_uses; 210 of.min_uses = clcf->open_file_cache_min_uses;
211 of.test_only = 1;
211 of.errors = clcf->open_file_cache_errors; 212 of.errors = clcf->open_file_cache_errors;
212 of.events = clcf->open_file_cache_events; 213 of.events = clcf->open_file_cache_events;
213 214
214 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool) 215 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
215 != NGX_OK) 216 != NGX_OK)
216 { 217 {
217 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, of.err, 218 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, of.err,
218 ngx_open_file_n " \"%s\" failed", path.data); 219 "%s \"%s\" failed", of.failed, path.data);
219 220
220 if (of.err == 0) { 221 if (of.err == 0) {
221 return NGX_HTTP_INTERNAL_SERVER_ERROR; 222 return NGX_HTTP_INTERNAL_SERVER_ERROR;
222 } 223 }
223 224
237 238
238 if (of.err == NGX_ENOENT) { 239 if (of.err == NGX_ENOENT) {
239 continue; 240 continue;
240 } 241 }
241 242
242 ngx_log_error(NGX_LOG_ERR, r->connection->log, of.err, 243 ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err,
243 ngx_open_file_n " \"%s\" failed", path.data); 244 "%s \"%s\" failed", of.failed, path.data);
244 245
245 return NGX_HTTP_INTERNAL_SERVER_ERROR; 246 return NGX_HTTP_INTERNAL_SERVER_ERROR;
246 } 247 }
247 248
248 uri.len = r->uri.len + len - 1; 249 uri.len = r->uri.len + len - 1;
289 "http index check dir: \"%V\"", &dir); 290 "http index check dir: \"%V\"", &dir);
290 291
291 ngx_memzero(&of, sizeof(ngx_open_file_info_t)); 292 ngx_memzero(&of, sizeof(ngx_open_file_info_t));
292 293
293 of.test_dir = 1; 294 of.test_dir = 1;
295 of.test_only = 1;
294 of.valid = clcf->open_file_cache_valid; 296 of.valid = clcf->open_file_cache_valid;
295 of.errors = clcf->open_file_cache_errors; 297 of.errors = clcf->open_file_cache_errors;
296 298
297 if (ngx_open_cached_file(clcf->open_file_cache, &dir, &of, r->pool) 299 if (ngx_open_cached_file(clcf->open_file_cache, &dir, &of, r->pool)
298 != NGX_OK) 300 != NGX_OK)
316 318
317 return NGX_OK; 319 return NGX_OK;
318 } 320 }
319 321
320 ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err, 322 ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err,
321 ngx_open_file_n " \"%s\" failed", dir.data); 323 "%s \"%s\" failed", of.failed, dir.data);
322 } 324 }
323 325
324 return NGX_HTTP_INTERNAL_SERVER_ERROR; 326 return NGX_HTTP_INTERNAL_SERVER_ERROR;
325 } 327 }
326 328