comparison src/http/ngx_http_core_module.c @ 4:4b2dafa26fe2 NGINX_0_1_2

nginx 0.1.2 *) Feature: the --user=USER, --group=GROUP, and --with-ld-opt=OPTIONS options in configure. *) Feature: the server_name directive supports *.domain.tld. *) Bugfix: the portability improvements. *) Bugfix: if configuration file was set in command line, the reconfiguration was impossible; bug appeared in 0.1.1. *) Bugfix: proxy module may get caught in an endless loop when sendfile is not used. *) Bugfix: with sendfile the response was not recoded according to the charset module directives; bug appeared in 0.1.1. *) Bugfix: very seldom bug in the kqueue processing. *) Bugfix: the gzip module compressed the proxied responses that was already compressed.
author Igor Sysoev <http://sysoev.ru>
date Thu, 21 Oct 2004 00:00:00 +0400
parents cc9f381affaa
children 80ba094c6b3e
comparison
equal deleted inserted replaced
3:8beaf7b3241f 4:4b2dafa26fe2
34 static int ngx_cmp_locations(const void *first, const void *second); 34 static int ngx_cmp_locations(const void *first, const void *second);
35 static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, 35 static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd,
36 void *dummy); 36 void *dummy);
37 static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); 37 static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
38 static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf); 38 static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf);
39 static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); 39 static char *ngx_http_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
40 static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd, 40 static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd,
41 void *conf); 41 void *conf);
42 static char *ngx_set_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); 42 static char *ngx_set_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
43 static char *ngx_set_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); 43 static char *ngx_set_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
44 static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); 44 static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
124 124
125 { ngx_string("listen"), 125 { ngx_string("listen"),
126 #if 0 126 #if 0
127 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, 127 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
128 #else 128 #else
129 NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, 129 NGX_HTTP_SRV_CONF|NGX_CONF_TAKE12,
130 #endif 130 #endif
131 ngx_set_listen, 131 ngx_http_listen,
132 NGX_HTTP_SRV_CONF_OFFSET, 132 NGX_HTTP_SRV_CONF_OFFSET,
133 0, 133 0,
134 NULL }, 134 NULL },
135 135
136 { ngx_string("server_name"), 136 { ngx_string("server_name"),
574 found = 0; 574 found = 0;
575 575
576 clcfp = locations->elts; 576 clcfp = locations->elts;
577 for (i = 0; i < locations->nelts; i++) { 577 for (i = 0; i < locations->nelts; i++) {
578 578
579 #if (HAVE_PCRE) 579 #if (NGX_PCRE)
580 if (clcfp[i]->regex) { 580 if (clcfp[i]->regex) {
581 break; 581 break;
582 } 582 }
583 #endif 583 #endif
584 584
636 return rc; 636 return rc;
637 } 637 }
638 } 638 }
639 } 639 }
640 640
641 #if (HAVE_PCRE) 641 #if (NGX_PCRE)
642 642
643 /* regex matches */ 643 /* regex matches */
644 644
645 for (/* void */; i < locations->nelts; i++) { 645 for (/* void */; i < locations->nelts; i++) {
646 646
671 r->loc_conf = clcfp[i]->loc_conf; 671 r->loc_conf = clcfp[i]->loc_conf;
672 672
673 return NGX_HTTP_LOCATION_REGEX; 673 return NGX_HTTP_LOCATION_REGEX;
674 } 674 }
675 675
676 #endif /* HAVE_PCRE */ 676 #endif /* NGX_PCRE */
677 677
678 return NGX_OK; 678 return NGX_OK;
679 } 679 }
680 680
681 681
989 ngx_http_core_loc_conf_t *first, *second; 989 ngx_http_core_loc_conf_t *first, *second;
990 990
991 first = *(ngx_http_core_loc_conf_t **) one; 991 first = *(ngx_http_core_loc_conf_t **) one;
992 second = *(ngx_http_core_loc_conf_t **) two; 992 second = *(ngx_http_core_loc_conf_t **) two;
993 993
994 #if (HAVE_PCRE) 994 #if (NGX_PCRE)
995 995
996 if (first->regex && !second->regex) { 996 if (first->regex && !second->regex) {
997 /* shift the regex matches to the end */ 997 /* shift the regex matches to the end */
998 return 1; 998 return 1;
999 } 999 }
1024 ngx_conf_t pcf; 1024 ngx_conf_t pcf;
1025 ngx_http_module_t *module; 1025 ngx_http_module_t *module;
1026 ngx_http_conf_ctx_t *ctx, *pctx; 1026 ngx_http_conf_ctx_t *ctx, *pctx;
1027 ngx_http_core_srv_conf_t *cscf; 1027 ngx_http_core_srv_conf_t *cscf;
1028 ngx_http_core_loc_conf_t *clcf, *pclcf, **clcfp; 1028 ngx_http_core_loc_conf_t *clcf, *pclcf, **clcfp;
1029 #if (HAVE_PCRE) 1029 #if (NGX_PCRE)
1030 ngx_str_t err; 1030 ngx_str_t err;
1031 u_char errstr[NGX_MAX_CONF_ERRSTR]; 1031 u_char errstr[NGX_MAX_CONF_ERRSTR];
1032 #endif 1032 #endif
1033 1033
1034 if (!(ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)))) { 1034 if (!(ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)))) {
1074 } else if ((value[1].len == 1 && value[1].data[0] == '~') 1074 } else if ((value[1].len == 1 && value[1].data[0] == '~')
1075 || (value[1].len == 2 1075 || (value[1].len == 2
1076 && value[1].data[0] == '~' 1076 && value[1].data[0] == '~'
1077 && value[1].data[1] == '*')) 1077 && value[1].data[1] == '*'))
1078 { 1078 {
1079 #if (HAVE_PCRE) 1079 #if (NGX_PCRE)
1080 err.len = NGX_MAX_CONF_ERRSTR; 1080 err.len = NGX_MAX_CONF_ERRSTR;
1081 err.data = errstr; 1081 err.data = errstr;
1082 1082
1083 clcf->regex = ngx_regex_compile(&value[2], 1083 clcf->regex = ngx_regex_compile(&value[2],
1084 value[1].len == 2 ? NGX_REGEX_CASELESS: 0, 1084 value[1].len == 2 ? NGX_REGEX_CASELESS: 0,
1127 "the exact location \"%s\"", 1127 "the exact location \"%s\"",
1128 clcf->name.data, pclcf->name.data); 1128 clcf->name.data, pclcf->name.data);
1129 return NGX_CONF_ERROR; 1129 return NGX_CONF_ERROR;
1130 } 1130 }
1131 1131
1132 #if (HAVE_PCRE) 1132 #if (NGX_PCRE)
1133 if (clcf->regex == NULL 1133 if (clcf->regex == NULL
1134 && ngx_strncmp(clcf->name.data, pclcf->name.data, pclcf->name.len) 1134 && ngx_strncmp(clcf->name.data, pclcf->name.data, pclcf->name.len)
1135 != 0) 1135 != 0)
1136 #else 1136 #else
1137 if (ngx_strncmp(clcf->name.data, pclcf->name.data, pclcf->name.len) 1137 if (ngx_strncmp(clcf->name.data, pclcf->name.data, pclcf->name.len)
1321 return NGX_CONF_ERROR; 1321 return NGX_CONF_ERROR;
1322 } 1322 }
1323 1323
1324 n->name.len = ngx_strlen(n->name.data); 1324 n->name.len = ngx_strlen(n->name.data);
1325 n->core_srv_conf = conf; 1325 n->core_srv_conf = conf;
1326 1326 n->wildcard = 0;
1327 #if 0 1327
1328 ctx = (ngx_http_conf_ctx_t *)
1329 cf->cycle->conf_ctx[ngx_http_module.index];
1330 cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
1331 #endif
1332 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); 1328 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
1333 1329
1334 if (cmcf->max_server_name_len < n->name.len) { 1330 if (cmcf->max_server_name_len < n->name.len) {
1335 cmcf->max_server_name_len = n->name.len; 1331 cmcf->max_server_name_len = n->name.len;
1336 } 1332 }
1510 1506
1511 return NGX_CONF_OK; 1507 return NGX_CONF_OK;
1512 } 1508 }
1513 1509
1514 1510
1515 static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 1511 static char *ngx_http_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1516 { 1512 {
1517 ngx_http_core_srv_conf_t *scf = conf; 1513 ngx_http_core_srv_conf_t *scf = conf;
1518 1514
1519 u_char *addr; 1515 u_char *addr;
1520 ngx_int_t port; 1516 ngx_int_t port;
1605 ngx_uint_t i; 1601 ngx_uint_t i;
1606 ngx_str_t *value; 1602 ngx_str_t *value;
1607 ngx_http_server_name_t *sn; 1603 ngx_http_server_name_t *sn;
1608 ngx_http_core_main_conf_t *cmcf; 1604 ngx_http_core_main_conf_t *cmcf;
1609 1605
1610 /* TODO: several names */
1611 /* TODO: warn about duplicate 'server_name' directives */ 1606 /* TODO: warn about duplicate 'server_name' directives */
1612 1607
1613 #if 0
1614 ctx = (ngx_http_conf_ctx_t *) cf->cycle->conf_ctx[ngx_http_module.index];
1615 cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
1616 #endif
1617 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); 1608 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
1618 1609
1619 value = cf->args->elts; 1610 value = cf->args->elts;
1620 1611
1621 for (i = 1; i < cf->args->nelts; i++) { 1612 for (i = 1; i < cf->args->nelts; i++) {
1625 "in \"%s\" directive", 1616 "in \"%s\" directive",
1626 value[i].data, cmd->name.data); 1617 value[i].data, cmd->name.data);
1627 return NGX_CONF_ERROR; 1618 return NGX_CONF_ERROR;
1628 } 1619 }
1629 1620
1630 ngx_test_null(sn, ngx_push_array(&scf->server_names), NGX_CONF_ERROR); 1621 if (!(sn = ngx_array_push(&scf->server_names))) {
1622 return NGX_CONF_ERROR;
1623 }
1631 1624
1632 sn->name.len = value[i].len; 1625 sn->name.len = value[i].len;
1633 sn->name.data = value[i].data; 1626 sn->name.data = value[i].data;
1634 sn->core_srv_conf = scf; 1627 sn->core_srv_conf = scf;
1628
1629 if (sn->name.data[0] == '*') {
1630 sn->name.len--;
1631 sn->name.data++;
1632 sn->wildcard = 1;
1633
1634 } else {
1635 sn->wildcard = 0;
1636 }
1635 1637
1636 if (cmcf->max_server_name_len < sn->name.len) { 1638 if (cmcf->max_server_name_len < sn->name.len) {
1637 cmcf->max_server_name_len = sn->name.len; 1639 cmcf->max_server_name_len = sn->name.len;
1638 } 1640 }
1639 } 1641 }
1804 1806
1805 static char *ngx_http_lowat_check(ngx_conf_t *cf, void *post, void *data) 1807 static char *ngx_http_lowat_check(ngx_conf_t *cf, void *post, void *data)
1806 { 1808 {
1807 ssize_t *np = data; 1809 ssize_t *np = data;
1808 1810
1809 #if __FreeBSD__ 1811 #if (NGX_FREEBSD)
1810 1812
1811 if (*np >= ngx_freebsd_net_inet_tcp_sendspace) { 1813 if (*np >= ngx_freebsd_net_inet_tcp_sendspace) {
1812 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 1814 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1813 "\"send_lowat\" must be less than %d " 1815 "\"send_lowat\" must be less than %d "
1814 "(sysctl net.inet.tcp.sendspace)", 1816 "(sysctl net.inet.tcp.sendspace)",