Mercurial > hg > nginx-vendor-current
comparison src/core/ngx_cycle.c @ 72:b31656313b59 NGINX_0_1_36
nginx 0.1.36
*) Change: if the request header has duplicate the "Host",
"Connection", "Content-Length", or "Authorization" lines, then nginx
now returns the 400 error.
*) Change: the "post_accept_timeout" directive was canceled.
*) Feature: the "default", "af=", "bl=", "deferred", and "bind"
parameters of the "listen" directive.
*) Feature: the FreeBSD accept filters support.
*) Feature: the Linux TCP_DEFER_ACCEPT support.
*) Bugfix: the ngx_http_autoindex_module did not support the file names
in UTF-8.
*) Bugfix: the new log file can be rotated by the -USR1 signal only if
the reconfiguration by the -HUP signal was made twice.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 15 Jun 2005 00:00:00 +0400 |
parents | 818201e5a553 |
children | 77969b24f355 |
comparison
equal
deleted
inserted
replaced
71:66f1f40f29d6 | 72:b31656313b59 |
---|---|
37 #endif | 37 #endif |
38 | 38 |
39 | 39 |
40 ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle) | 40 ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle) |
41 { | 41 { |
42 void *rv; | 42 void *rv; |
43 ngx_uint_t i, n, failed; | 43 ngx_uint_t i, n, failed; |
44 ngx_log_t *log; | 44 ngx_log_t *log; |
45 ngx_conf_t conf; | 45 ngx_conf_t conf; |
46 ngx_pool_t *pool; | 46 ngx_pool_t *pool; |
47 ngx_cycle_t *cycle, **old; | 47 ngx_cycle_t *cycle, **old; |
48 ngx_socket_t fd; | 48 ngx_socket_t fd; |
49 ngx_list_part_t *part; | 49 ngx_list_part_t *part; |
50 ngx_open_file_t *file; | 50 ngx_open_file_t *file; |
51 ngx_listening_t *ls, *nls; | 51 ngx_listening_t *ls, *nls; |
52 ngx_core_conf_t *ccf; | 52 ngx_core_conf_t *ccf; |
53 ngx_core_module_t *module; | 53 ngx_core_module_t *module; |
54 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) | |
55 struct accept_filter_arg af; | |
56 #endif | |
57 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) | |
58 int timeout; | |
59 #endif | |
54 | 60 |
55 log = old_cycle->log; | 61 log = old_cycle->log; |
56 | 62 |
57 pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log); | 63 pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log); |
58 if (pool == NULL) { | 64 if (pool == NULL) { |
305 if (ls[i].ignore) { | 311 if (ls[i].ignore) { |
306 continue; | 312 continue; |
307 } | 313 } |
308 | 314 |
309 if (ngx_cmp_sockaddr(nls[n].sockaddr, ls[i].sockaddr) | 315 if (ngx_cmp_sockaddr(nls[n].sockaddr, ls[i].sockaddr) |
310 == NGX_OK) | 316 == NGX_OK) |
311 { | 317 { |
312 fd = ls[i].fd; | 318 fd = ls[i].fd; |
313 #if (NGX_WIN32) | 319 #if (NGX_WIN32) |
314 /* | 320 /* |
315 * Winsock assignes a socket number divisible by 4 so | 321 * Winsock assignes a socket number divisible by 4 so |
328 failed = 1; | 334 failed = 1; |
329 break; | 335 break; |
330 } | 336 } |
331 | 337 |
332 nls[n].fd = ls[i].fd; | 338 nls[n].fd = ls[i].fd; |
333 nls[i].remain = 1; | 339 nls[n].remain = 1; |
334 ls[i].remain = 1; | 340 ls[i].remain = 1; |
341 | |
342 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) | |
343 | |
344 /* | |
345 * FreeBSD, except the most recent versions, | |
346 * can not remove accept filter | |
347 */ | |
348 nls[n].deferred_accept = ls[i].deferred_accept; | |
349 | |
350 if (ls[i].accept_filter && nls[n].accept_filter) { | |
351 if (ngx_strcmp(ls[i].accept_filter, | |
352 nls[n].accept_filter) != 0) | |
353 { | |
354 nls[n].delete_deferred = 1; | |
355 nls[n].add_deferred = 1; | |
356 } | |
357 | |
358 } else if (ls[i].accept_filter) { | |
359 nls[n].delete_deferred = 1; | |
360 | |
361 } else if (nls[n].accept_filter) { | |
362 nls[n].add_deferred = 1; | |
363 } | |
364 #endif | |
365 | |
366 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) | |
367 | |
368 if (ls[n].deferred_accept && !nls[n].deferred_accept) { | |
369 nls[n].delete_deferred = 1; | |
370 | |
371 } else if (ls[i].deferred_accept | |
372 != nls[n].deferred_accept) | |
373 { | |
374 nls[n].add_deferred = 1; | |
375 } | |
376 #endif | |
335 break; | 377 break; |
336 } | 378 } |
337 } | 379 } |
338 | 380 |
339 if (nls[n].fd == -1) { | 381 if (nls[n].fd == -1) { |
343 | 385 |
344 } else { | 386 } else { |
345 ls = cycle->listening.elts; | 387 ls = cycle->listening.elts; |
346 for (i = 0; i < cycle->listening.nelts; i++) { | 388 for (i = 0; i < cycle->listening.nelts; i++) { |
347 ls[i].open = 1; | 389 ls[i].open = 1; |
390 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) | |
391 if (ls[i].accept_filter) { | |
392 ls[i].add_deferred = 1; | |
393 } | |
394 #endif | |
395 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) | |
396 if (ls[i].deferred_accept) { | |
397 ls[i].add_deferred = 1; | |
398 } | |
399 #endif | |
348 } | 400 } |
349 } | 401 } |
350 | 402 |
351 if (!ngx_test_config && !failed) { | 403 if (!ngx_test_config && !failed) { |
352 if (ngx_open_listening_sockets(cycle) == NGX_ERROR) { | 404 if (ngx_open_listening_sockets(cycle) == NGX_ERROR) { |
353 failed = 1; | 405 failed = 1; |
354 } | 406 } |
407 | |
408 #if (NGX_HAVE_DEFERRED_ACCEPT) | |
409 | |
410 if (!failed) { | |
411 ls = cycle->listening.elts; | |
412 for (i = 0; i < cycle->listening.nelts; i++) { | |
413 | |
414 #ifdef SO_ACCEPTFILTER | |
415 if (ls[i].delete_deferred) { | |
416 if (setsockopt(ls[i].fd, SOL_SOCKET, SO_ACCEPTFILTER, | |
417 NULL, 0) == -1) | |
418 { | |
419 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, | |
420 "setsockopt(SO_ACCEPTFILTER, NULL) " | |
421 "for %V failed, ignored", | |
422 &ls[i].addr_text); | |
423 | |
424 if (ls[i].accept_filter) { | |
425 ngx_log_error(NGX_LOG_ALERT, log, 0, | |
426 "could not change the accept filter " | |
427 "to \"%s\" for %V, ignored", | |
428 ls[i].accept_filter, &ls[i].addr_text); | |
429 } | |
430 | |
431 continue; | |
432 } | |
433 | |
434 ls[i].deferred_accept = 0; | |
435 } | |
436 | |
437 if (ls[i].add_deferred) { | |
438 ngx_memzero(&af, sizeof(struct accept_filter_arg)); | |
439 (void) ngx_cpystrn((u_char *) af.af_name, | |
440 (u_char *) ls[i].accept_filter, 16); | |
441 | |
442 if (setsockopt(ls[i].fd, SOL_SOCKET, SO_ACCEPTFILTER, | |
443 &af, sizeof(struct accept_filter_arg)) == -1) | |
444 { | |
445 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, | |
446 "setsockopt(SO_ACCEPTFILTER, \"%s\") " | |
447 "for %V failed, ignored", | |
448 ls[i].accept_filter, &ls[i].addr_text); | |
449 continue; | |
450 } | |
451 | |
452 ls[i].deferred_accept = 1; | |
453 } | |
454 #endif | |
455 | |
456 #ifdef TCP_DEFER_ACCEPT | |
457 if (ls[i].add_deferred || ls[i].delete_deferred) { | |
458 timeout = 0; | |
459 | |
460 if (ls[i].add_deferred) { | |
461 timeout = (int) (ls[i].post_accept_timeout / 1000); | |
462 } | |
463 | |
464 if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, | |
465 &timeout, sizeof(int)) == -1) | |
466 { | |
467 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, | |
468 "setsockopt(TCP_DEFER_ACCEPT, %d) " | |
469 "for %V failed, ignored", | |
470 timeout, &ls[i].addr_text); | |
471 continue; | |
472 } | |
473 } | |
474 | |
475 if (ls[i].add_deferred) { | |
476 ls[i].deferred_accept = 1; | |
477 } | |
478 #endif | |
479 } | |
480 } | |
481 #endif | |
355 } | 482 } |
356 } | 483 } |
357 | 484 |
358 if (failed) { | 485 if (failed) { |
359 | 486 |
680 if (i >= part->nelts) { | 807 if (i >= part->nelts) { |
681 if (part->next == NULL) { | 808 if (part->next == NULL) { |
682 break; | 809 break; |
683 } | 810 } |
684 part = part->next; | 811 part = part->next; |
812 file = part->elts; | |
685 i = 0; | 813 i = 0; |
686 } | 814 } |
687 | 815 |
688 if (file[i].name.data == NULL) { | 816 if (file[i].name.data == NULL) { |
689 continue; | 817 continue; |