comparison src/http/ngx_http.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 8ad297c88dcb
children 71c46860eb55
comparison
equal deleted inserted replaced
71:66f1f40f29d6 72:b31656313b59
64 64
65 static char * 65 static char *
66 ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 66 ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
67 { 67 {
68 char *rv; 68 char *rv;
69 ngx_uint_t mi, m, s, l, p, a, n; 69 ngx_uint_t mi, m, s, l, p, a, n, key;
70 ngx_uint_t port_found, addr_found, virtual_names, key; 70 ngx_uint_t port_found, addr_found;
71 ngx_uint_t virtual_names, separate_binding;
71 ngx_conf_t pcf; 72 ngx_conf_t pcf;
72 ngx_array_t in_ports; 73 ngx_array_t in_ports;
73 ngx_listening_t *ls; 74 ngx_listening_t *ls;
74 ngx_http_listen_t *lscf; 75 ngx_http_listen_t *lscf;
75 ngx_http_module_t *module; 76 ngx_http_module_t *module;
406 /* 407 /*
407 * check the duplicate "default" server 408 * check the duplicate "default" server
408 * for this address:port 409 * for this address:port
409 */ 410 */
410 411
411 if (lscf[l].default_server) { 412 if (lscf[l].conf.default_server) {
412 413
413 if (in_addr[a].default_server) { 414 if (in_addr[a].conf.default_server) {
414 ngx_log_error(NGX_LOG_ERR, cf->log, 0, 415 ngx_log_error(NGX_LOG_ERR, cf->log, 0,
415 "the duplicate default server in %V:%d", 416 "the duplicate default server in %V:%d",
416 &lscf[l].file_name, lscf[l].line); 417 &lscf[l].file_name, lscf[l].line);
417 418
418 return NGX_CONF_ERROR; 419 return NGX_CONF_ERROR;
419 } 420 }
420 421
421 in_addr[a].core_srv_conf = cscfp[s]; 422 in_addr[a].core_srv_conf = cscfp[s];
422 in_addr[a].default_server = 1; 423 in_addr[a].conf.default_server = 1;
423 } 424 }
424 425
425 addr_found = 1; 426 addr_found = 1;
426 427
427 break; 428 break;
447 448
448 in_addr[a].addr = lscf[l].addr; 449 in_addr[a].addr = lscf[l].addr;
449 in_addr[a].names.elts = NULL; 450 in_addr[a].names.elts = NULL;
450 in_addr[a].hash = NULL; 451 in_addr[a].hash = NULL;
451 in_addr[a].wildcards.elts = NULL; 452 in_addr[a].wildcards.elts = NULL;
452 in_addr[a].default_server = lscf[l].default_server;
453 in_addr[a].core_srv_conf = cscfp[s]; 453 in_addr[a].core_srv_conf = cscfp[s];
454 in_addr[a].conf = lscf[l].conf;
454 455
455 if (ngx_http_add_names(cf, &in_addr[a], cscfp[s]) 456 if (ngx_http_add_names(cf, &in_addr[a], cscfp[s])
456 != NGX_OK) 457 != NGX_OK)
457 { 458 {
458 return NGX_CONF_ERROR; 459 return NGX_CONF_ERROR;
516 /* AF_INET only */ 517 /* AF_INET only */
517 518
518 in_port = in_ports.elts; 519 in_port = in_ports.elts;
519 for (p = 0; p < in_ports.nelts; p++) { 520 for (p = 0; p < in_ports.nelts; p++) {
520 521
522 separate_binding = 0;
523
521 /* 524 /*
522 * check whether all name-based servers have the same configuraiton 525 * check whether all name-based servers have the same configuraiton
523 * as the default server, or some servers restrict the host names 526 * as the default server, or some servers restrict the host names
524 */ 527 */
525 528
526 in_addr = in_port[p].addrs.elts; 529 in_addr = in_port[p].addrs.elts;
527 for (a = 0; a < in_port[p].addrs.nelts; a++) { 530 for (a = 0; a < in_port[p].addrs.nelts; a++) {
531
532 if (in_addr[a].conf.bind) {
533 separate_binding = 1;
534 }
528 535
529 virtual_names = 0; 536 virtual_names = 0;
530 537
531 name = in_addr[a].names.elts; 538 name = in_addr[a].names.elts;
532 for (n = 0; n < in_addr[a].names.nelts; n++) { 539 for (n = 0; n < in_addr[a].names.nelts; n++) {
606 /* 613 /*
607 * if there is the binding to the "*:port" then we need to bind() 614 * if there is the binding to the "*:port" then we need to bind()
608 * to the "*:port" only and ignore the other bindings 615 * to the "*:port" only and ignore the other bindings
609 */ 616 */
610 617
611 if (in_addr[a - 1].addr == INADDR_ANY) { 618 if (in_addr[a - 1].addr == INADDR_ANY && !separate_binding) {
612 a--; 619 a--;
613 620
614 } else { 621 } else {
615 a = 0; 622 a = 0;
616 } 623 }
622 in_port[p].port); 629 in_port[p].port);
623 if (ls == NULL) { 630 if (ls == NULL) {
624 return NGX_CONF_ERROR; 631 return NGX_CONF_ERROR;
625 } 632 }
626 633
627 ls->backlog = -1;
628
629 ls->addr_ntop = 1; 634 ls->addr_ntop = 1;
630 635
631 ls->handler = ngx_http_init_connection; 636 ls->handler = ngx_http_init_connection;
632 637
633 cscf = in_addr[a].core_srv_conf; 638 cscf = in_addr[a].core_srv_conf;
634 ls->pool_size = cscf->connection_pool_size; 639 ls->pool_size = cscf->connection_pool_size;
635 ls->post_accept_timeout = cscf->post_accept_timeout; 640 ls->post_accept_timeout = cscf->client_header_timeout;
636 641
637 clcf = cscf->ctx->loc_conf[ngx_http_core_module.ctx_index]; 642 clcf = cscf->ctx->loc_conf[ngx_http_core_module.ctx_index];
638 ls->log = clcf->err_log; 643 ls->log = clcf->err_log;
639 644
640 #if (NGX_WIN32) 645 #if (NGX_WIN32)
641 iocpcf = ngx_event_get_conf(cf->cycle->conf_ctx, ngx_iocp_module); 646 iocpcf = ngx_event_get_conf(cf->cycle->conf_ctx, ngx_iocp_module);
642 if (iocpcf->acceptex_read) { 647 if (iocpcf->acceptex_read) {
643 ls->post_accept_buffer_size = cscf->client_header_buffer_size; 648 ls->post_accept_buffer_size = cscf->client_header_buffer_size;
644 } 649 }
650 #endif
651
652 ls->backlog = in_addr[a].conf.backlog;
653
654 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
655 ls->accept_filter = in_addr[a].conf.accept_filter;
656 #endif
657
658 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
659 ls->deferred_accept = in_addr[a].conf.deferred_accept;
645 #endif 660 #endif
646 661
647 ls->ctx = ctx; 662 ls->ctx = ctx;
648 663
649 if (in_port[p].addrs.nelts > 1) { 664 if (in_port[p].addrs.nelts > 1) {
764 779
765 in_addr->addr = lscf->addr; 780 in_addr->addr = lscf->addr;
766 in_addr->names.elts = NULL; 781 in_addr->names.elts = NULL;
767 in_addr->hash = NULL; 782 in_addr->hash = NULL;
768 in_addr->wildcards.elts = NULL; 783 in_addr->wildcards.elts = NULL;
769 in_addr->default_server = lscf->default_server;
770 in_addr->core_srv_conf = cscf; 784 in_addr->core_srv_conf = cscf;
785 in_addr->conf = lscf->conf;
771 786
772 #if (NGX_DEBUG) 787 #if (NGX_DEBUG)
773 { 788 {
774 u_char text[20]; 789 u_char text[20];
775 ngx_inet_ntop(AF_INET, &in_addr->addr, text, 20); 790 ngx_inet_ntop(AF_INET, &in_addr->addr, text, 20);