comparison src/http/modules/ngx_http_index_module.c @ 112:408f195b3482 NGINX_0_3_3

nginx 0.3.3 *) Change: the "bl" and "af" parameters of the "listen" directive was renamed to the "backlog" and "accept_filter". *) Feature: the "rcvbuf" and "sndbuf" parameters of the "listen" directive. *) Change: the "$msec" log parameter does not require now the additional the gettimeofday() system call. *) Feature: the -t switch now tests the "listen" directives. *) Bugfix: if the invalid address was specified in the "listen" directive, then after the -HUP signal nginx left an open socket in the CLOSED state. *) Bugfix: the mime type may be incorrectly set to default value for index file with variable in the name; bug appeared in 0.3.0. *) Feature: the "timer_resolution" directive. *) Feature: the millisecond "$upstream_response_time" log parameter. *) Bugfix: a temporary file with client request body now is removed just after the response header was transferred to a client. *) Bugfix: OpenSSL 0.9.6 compatibility. *) Bugfix: the SSL certificate and key file paths could not be relative. *) Bugfix: the "ssl_prefer_server_ciphers" directive did not work in the ngx_imap_ssl_module. *) Bugfix: the "ssl_protocols" directive allowed to specify the single protocol only.
author Igor Sysoev <http://sysoev.ru>
date Wed, 19 Oct 2005 00:00:00 +0400
parents 45f7329b4bd0
children d25a1d6034f1
comparison
equal deleted inserted replaced
111:a175b609c76d 112:408f195b3482
124 ngx_str_t uri; 124 ngx_str_t uri;
125 ngx_log_t *log; 125 ngx_log_t *log;
126 ngx_uint_t i; 126 ngx_uint_t i;
127 ngx_http_index_t *index; 127 ngx_http_index_t *index;
128 ngx_http_index_ctx_t *ctx; 128 ngx_http_index_ctx_t *ctx;
129 ngx_pool_cleanup_file_t *cln; 129 ngx_pool_cleanup_t *cln;
130 ngx_pool_cleanup_file_t *clnf;
130 ngx_http_script_code_pt code; 131 ngx_http_script_code_pt code;
131 ngx_http_script_engine_t e; 132 ngx_http_script_engine_t e;
132 ngx_http_core_loc_conf_t *clcf; 133 ngx_http_core_loc_conf_t *clcf;
133 ngx_http_index_loc_conf_t *ilcf; 134 ngx_http_index_loc_conf_t *ilcf;
134 ngx_http_script_len_code_pt lcode; 135 ngx_http_script_len_code_pt lcode;
178 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); 179 ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
179 180
180 e.ip = index[i].lengths->elts; 181 e.ip = index[i].lengths->elts;
181 e.request = r; 182 e.request = r;
182 183
183 /* 1 byte for terminating '\0' and 4 bytes is preallocation */ 184 /* 1 byte for terminating '\0' */
184 185
185 len = 1 + 4; 186 len = 1;
186 187
187 while (*(uintptr_t *) e.ip) { 188 while (*(uintptr_t *) e.ip) {
188 lcode = *(ngx_http_script_len_code_pt *) e.ip; 189 lcode = *(ngx_http_script_len_code_pt *) e.ip;
189 len += lcode(&e); 190 len += lcode(&e);
190 } 191 }
191 192
192 ctx->index.len = len; 193 ctx->index.len = len;
194
195 /* 16 bytes are preallocation */
196
197 len += 16;
193 } 198 }
194 199
195 if (len > ctx->path.len) { 200 if (len > ctx->path.len) {
196 201
197 last = ngx_http_map_uri_to_path(r, &ctx->path, len); 202 last = ngx_http_map_uri_to_path(r, &ctx->path, len);
226 } 231 }
227 232
228 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, 233 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0,
229 "open index \"%s\"", ctx->path.data); 234 "open index \"%s\"", ctx->path.data);
230 235
236 cln = ngx_pool_cleanup_add(r->pool, sizeof(ngx_pool_cleanup_file_t));
237 if (cln == NULL) {
238 return NGX_HTTP_INTERNAL_SERVER_ERROR;
239 }
240
231 fd = ngx_open_file(ctx->path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN); 241 fd = ngx_open_file(ctx->path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
232 242
233 if (fd == (ngx_fd_t) NGX_AGAIN) { 243 if (fd == (ngx_fd_t) NGX_AGAIN) {
234 ctx->current = i; 244 ctx->current = i;
235 return NGX_AGAIN; 245 return NGX_AGAIN;
266 ngx_open_file_n " \"%s\" failed", ctx->path.data); 276 ngx_open_file_n " \"%s\" failed", ctx->path.data);
267 277
268 return NGX_HTTP_INTERNAL_SERVER_ERROR; 278 return NGX_HTTP_INTERNAL_SERVER_ERROR;
269 } 279 }
270 280
271 281 cln->handler = ngx_pool_cleanup_file;
272 cln = ngx_palloc(r->pool, sizeof(ngx_pool_cleanup_file_t)); 282 clnf = cln->data;
273 if (cln == NULL) { 283
274 return NGX_HTTP_INTERNAL_SERVER_ERROR; 284 clnf->fd = fd;
275 } 285 clnf->name = ctx->path.data;
276 286 clnf->log = r->pool->log;
277 cln->fd = fd;
278 cln->name = ctx->path.data;
279 cln->log = r->pool->log;
280
281 if (ngx_pool_cleanup_add(r->pool, ngx_pool_cleanup_file, cln) == NULL) {
282 return NGX_HTTP_INTERNAL_SERVER_ERROR;
283 }
284 287
285 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 288 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
286 289
287 uri.len = r->uri.len + ctx->index.len - 1; 290 uri.len = r->uri.len + ctx->index.len - 1;
288 291