comparison src/http/ngx_http_core_module.c @ 118:5bf52498665c

nginx-0.0.1-2003-07-18-18:44:05 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 18 Jul 2003 14:44:05 +0000
parents be27f922b9a2
children cd54bcbaf3b5
comparison
equal deleted inserted replaced
117:f6e3c5d019b6 118:5bf52498665c
819 ngx_test_null(n, ngx_push_array(&conf->server_names), NGX_CONF_ERROR); 819 ngx_test_null(n, ngx_push_array(&conf->server_names), NGX_CONF_ERROR);
820 ngx_test_null(n->name.data, ngx_palloc(pool, NGX_MAXHOSTNAMELEN), 820 ngx_test_null(n->name.data, ngx_palloc(pool, NGX_MAXHOSTNAMELEN),
821 NGX_CONF_ERROR); 821 NGX_CONF_ERROR);
822 822
823 if (gethostname(n->name.data, NGX_MAXHOSTNAMELEN) == -1) { 823 if (gethostname(n->name.data, NGX_MAXHOSTNAMELEN) == -1) {
824 #if 0
825 ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
826 "gethostname() failed");
827 return NGX_CONF_ERROR;
828 #endif
829
824 err = ngx_errno; 830 err = ngx_errno;
825 len = ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1, 831 len = ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
826 "gethostname() failed (%d: ", err); 832 "gethostname() failed (%d: ", err);
827 len += ngx_strerror_r(err, ngx_conf_errstr + len, 833 len += ngx_strerror_r(err, ngx_conf_errstr + len,
828 sizeof(ngx_conf_errstr) - len - 1); 834 sizeof(ngx_conf_errstr) - len - 1);
992 ls->port = 80; 998 ls->port = 80;
993 999
994 } else if ((ls->port == NGX_ERROR && p != 0) /* "listen host:NONNUMBER" */ 1000 } else if ((ls->port == NGX_ERROR && p != 0) /* "listen host:NONNUMBER" */
995 || (ls->port < 1 || ls->port > 65536)) { /* "listen 99999" */ 1001 || (ls->port < 1 || ls->port > 65536)) { /* "listen 99999" */
996 1002
997 ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1, 1003 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
998 "invalid port \"%s\", " 1004 "invalid port \"%s\" in \"%s\" directive, "
999 "it must be a number between 1 and 65535", 1005 "it must be a number between 1 and 65535",
1000 &addr[p]); 1006 &addr[p], cmd->name.data);
1001 return ngx_conf_errstr; 1007
1008 return NGX_CONF_ERROR;
1002 1009
1003 } else if (p == 0) { 1010 } else if (p == 0) {
1004 ls->addr = INADDR_ANY; 1011 ls->addr = INADDR_ANY;
1005 return NGX_CONF_OK; 1012 return NGX_CONF_OK;
1006 } 1013 }
1008 ls->addr = inet_addr(addr); 1015 ls->addr = inet_addr(addr);
1009 if (ls->addr == INADDR_NONE) { 1016 if (ls->addr == INADDR_NONE) {
1010 h = gethostbyname(addr); 1017 h = gethostbyname(addr);
1011 1018
1012 if (h == NULL || h->h_addr_list[0] == NULL) { 1019 if (h == NULL || h->h_addr_list[0] == NULL) {
1013 ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1, 1020 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1014 "can not resolve host \"%s\"", addr); 1021 "can not resolve host \"%s\" "
1015 return ngx_conf_errstr; 1022 "in \"%s\" directive", addr, cmd->name.data);
1023 return NGX_CONF_ERROR;
1016 } 1024 }
1017 1025
1018 ls->addr = *(u_int32_t *)(h->h_addr_list[0]); 1026 ls->addr = *(u_int32_t *)(h->h_addr_list[0]);
1019 } 1027 }
1020 1028
1035 1043
1036 value = cf->args->elts; 1044 value = cf->args->elts;
1037 1045
1038 for (i = 1; i < cf->args->nelts; i++) { 1046 for (i = 1; i < cf->args->nelts; i++) {
1039 if (value[i].len == 0) { 1047 if (value[i].len == 0) {
1040 ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1, 1048 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1041 "server name \"%s\" is invalid", value[i].data); 1049 "server name \"%s\" is invalid "
1042 return ngx_conf_errstr; 1050 "in \"%s\" directive",
1051 value[i].data, cmd->name.data);
1052 return NGX_CONF_ERROR;
1043 } 1053 }
1044 1054
1045 ngx_test_null(sn, ngx_push_array(&scf->server_names), NGX_CONF_ERROR); 1055 ngx_test_null(sn, ngx_push_array(&scf->server_names), NGX_CONF_ERROR);
1046 1056
1047 sn->name.len = value[i].len; 1057 sn->name.len = value[i].len;