Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-07-18 18:44:05 +0400
committerIgor Sysoev <igor@sysoev.ru>2003-07-18 18:44:05 +0400
commit8e1fbe61b69562d838aafda8d75798993f022d4a (patch)
tree62231a7769d67b79f11de63c079e05d93ee274ea /src
parent7f125081f4347118ba50066e6341e429b3a85c3c (diff)
nginx-0.0.1-2003-07-18-18:44:05 import
Diffstat (limited to 'src')
-rw-r--r--src/core/nginx.c7
-rw-r--r--src/core/ngx_conf_file.c32
-rw-r--r--src/core/ngx_conf_file.h7
-rw-r--r--src/http/modules/ngx_http_index_handler.c15
-rw-r--r--src/http/ngx_http_core_module.c32
5 files changed, 72 insertions, 21 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c
index ce2e30a4a..4bc9a218b 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -71,7 +71,12 @@ int main(int argc, char *const *argv)
ngx_core_conf_t *ccf;
#if (NGX_DEBUG) && (__FreeBSD__)
- malloc_options = "J";
+#if __FreeBSD_version >= 500014
+ _malloc_options
+#else
+ malloc_options
+#endif
+ = "J";
#endif
/* TODO */ ngx_max_sockets = -1;
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index ae4231f51..bea7a4c52 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -127,6 +127,7 @@ ngx_log_debug(cf->log, "token %d" _ rc);
&& ngx_strcmp(name->data, cmd->name.data) == 0)
{
+ found = 1;
#if 0
ngx_log_debug(cf->log, "command '%s'" _ cmd->name.data);
#endif
@@ -204,7 +205,6 @@ ngx_log_debug(cf->log, "rv: %d" _ rv);
#endif
if (rv == NGX_CONF_OK) {
- found = 1;
break;
} else if (rv == NGX_CONF_ERROR) {
@@ -220,7 +220,7 @@ ngx_log_debug(cf->log, "rv: %d" _ rv);
cf->conf_file->line);
} else {
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
- "%s %s in %s:%d",
+ "\"%s\" directive %s in %s:%d",
name->data, rv,
cf->conf_file->file.name.data,
cf->conf_file->line);
@@ -245,6 +245,10 @@ ngx_log_debug(cf->log, "rv: %d" _ rv);
rc = NGX_ERROR;
break;
}
+
+ if (rc == NGX_ERROR) {
+ break;
+ }
}
if (filename) {
@@ -471,6 +475,30 @@ ngx_log_debug(cf->log, "FOUND %d:'%s'" _ word->len _ word->data);
}
+void ngx_conf_log_error(int level, ngx_conf_t *cf, ngx_err_t err,
+ char *fmt, ...)
+{
+ int len;
+ char errstr[MAX_CONF_ERRSTR];
+ va_list args;
+
+ va_start(args, fmt);
+ len = ngx_vsnprintf(errstr, sizeof(errstr) - 1, fmt, args);
+ va_end(args);
+
+ if (err) {
+ len += ngx_snprintf(errstr + len, sizeof(errstr) - len - 1,
+ " (%d: ", err);
+ len += ngx_strerror_r(err, errstr + len, sizeof(errstr) - len - 1);
+ errstr[len++] = ')';
+ errstr[len++] = '\0';
+ }
+
+ ngx_log_error(level, cf->log, 0, "%s in %s:%d",
+ errstr, cf->conf_file->file.name.data, cf->conf_file->line);
+}
+
+
char *ngx_conf_set_core_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf)
{
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index 6f6a92ab9..f618d9be2 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -124,6 +124,7 @@ struct ngx_conf_s {
#define ngx_get_conf(conf_ctx, module) conf_ctx[module.index]
+
#define ngx_conf_init_value(conf, default) \
if (conf == NGX_CONF_UNSET) { \
conf = default; \
@@ -177,6 +178,10 @@ struct ngx_conf_s {
char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename);
+void ngx_conf_log_error(int level, ngx_conf_t *cf, ngx_err_t err,
+ char *fmt, ...);
+
+
char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
@@ -185,7 +190,7 @@ char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
char *ngx_conf_set_time_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
char *ngx_conf_set_core_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd,
- void *conf);
+ void *conf);
extern ngx_module_t *ngx_modules[];
extern ngx_cycle_t *ngx_cycle;
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c
index 7051480fc..c6c111716 100644
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -290,16 +290,19 @@ static char *ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd,
value = cf->args->elts;
if (value[1].data[0] == '/' && icf->indices.nelts == 0) {
- ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
- "first index \"%s\" must not be absolute", value[1].data);
- return ngx_conf_errstr;
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "first index \"%s\" in \"%s\" directive "
+ "must not be absolute",
+ value[1].data, cmd->name.data);
+ return NGX_CONF_ERROR;
}
for (i = 1; i < cf->args->nelts; i++) {
if (value[i].len == 0) {
- ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
- "index \"%s\" is invalid", value[i].data);
- return ngx_conf_errstr;
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "index \"%s\" in \"%s\" directive is invalid",
+ value[1].data, cmd->name.data);
+ return NGX_CONF_ERROR;
}
ngx_test_null(index, ngx_push_array(&icf->indices), NGX_CONF_ERROR);
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 0601f3f2c..aa3c58280 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -821,6 +821,12 @@ static char *ngx_http_core_merge_srv_conf(ngx_pool_t *pool,
NGX_CONF_ERROR);
if (gethostname(n->name.data, NGX_MAXHOSTNAMELEN) == -1) {
+#if 0
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
+ "gethostname() failed");
+ return NGX_CONF_ERROR;
+#endif
+
err = ngx_errno;
len = ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
"gethostname() failed (%d: ", err);
@@ -994,11 +1000,12 @@ static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
} else if ((ls->port == NGX_ERROR && p != 0) /* "listen host:NONNUMBER" */
|| (ls->port < 1 || ls->port > 65536)) { /* "listen 99999" */
- ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
- "invalid port \"%s\", "
- "it must be a number between 1 and 65535",
- &addr[p]);
- return ngx_conf_errstr;
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid port \"%s\" in \"%s\" directive, "
+ "it must be a number between 1 and 65535",
+ &addr[p], cmd->name.data);
+
+ return NGX_CONF_ERROR;
} else if (p == 0) {
ls->addr = INADDR_ANY;
@@ -1010,9 +1017,10 @@ static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
h = gethostbyname(addr);
if (h == NULL || h->h_addr_list[0] == NULL) {
- ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
- "can not resolve host \"%s\"", addr);
- return ngx_conf_errstr;
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "can not resolve host \"%s\" "
+ "in \"%s\" directive", addr, cmd->name.data);
+ return NGX_CONF_ERROR;
}
ls->addr = *(u_int32_t *)(h->h_addr_list[0]);
@@ -1037,9 +1045,11 @@ static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
for (i = 1; i < cf->args->nelts; i++) {
if (value[i].len == 0) {
- ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
- "server name \"%s\" is invalid", value[i].data);
- return ngx_conf_errstr;
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "server name \"%s\" is invalid "
+ "in \"%s\" directive",
+ value[i].data, cmd->name.data);
+ return NGX_CONF_ERROR;
}
ngx_test_null(sn, ngx_push_array(&scf->server_names), NGX_CONF_ERROR);