summaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/nginx.c10
-rw-r--r--src/core/ngx_cycle.c21
-rw-r--r--src/core/ngx_output_chain.c15
3 files changed, 38 insertions, 8 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 766257c8a..3c5f789fe 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -140,11 +140,19 @@ int main(int argc, char *const *argv)
cycle = ngx_init_cycle(&init_cycle);
if (cycle == NULL) {
+ if (ngx_test_config) {
+ ngx_log_error(NGX_LOG_EMERG, log, 0,
+ "the configuration file %s test failed",
+ init_cycle.conf_file.data);
+ }
+
return 1;
}
if (ngx_test_config) {
- ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "config syntax is ok");
+ ngx_log_error(NGX_LOG_INFO, log, 0,
+ "the configuration file %s was tested successfully",
+ init_cycle.conf_file.data);
return 0;
}
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index 94414ae12..bde3171ae 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -138,6 +138,12 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
return NULL;
}
+ if (ngx_test_config) {
+ ngx_log_error(NGX_LOG_INFO, log, 0,
+ "the configuration file %s syntax is ok",
+ cycle->conf_file.data);
+ }
+
for (i = 0; ngx_modules[i]; i++) {
if (ngx_modules[i]->type != NGX_CORE_MODULE) {
@@ -274,10 +280,12 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
#if !(WIN32)
- if (dup2(cycle->log->file->fd, STDERR_FILENO) == NGX_ERROR) {
- ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
- "dup2(STDERR) failed");
- failed = 1;
+ if (!failed && !ngx_test_config) {
+ if (dup2(cycle->log->file->fd, STDERR_FILENO) == NGX_ERROR) {
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
+ "dup2(STDERR) failed");
+ failed = 1;
+ }
}
#endif
@@ -299,6 +307,11 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
}
}
+ if (ngx_test_config) {
+ ngx_destroy_pool(pool);
+ return NULL;
+ }
+
ls = cycle->listening.elts;
for (i = 0; i < cycle->listening.nelts; i++) {
if (ls[i].new && ls[i].fd == -1) {
diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
index 285bd8340..94e410495 100644
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -20,7 +20,7 @@ int ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
ngx_chain_t *cl, *out, **last_out;
/*
- * the short path for the case when the chain ctx->in is empty
+ * the short path for the case when the ctx->in chain is empty
* and the incoming chain is empty too or it has the single hunk
* that does not require the copy
*/
@@ -54,9 +54,14 @@ int ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
while (ctx->in) {
+ /*
+ * cycle while there are the ctx->in hunks
+ * or there are the free output hunks to copy in
+ */
+
if (!ngx_output_chain_need_to_copy(ctx, ctx->in->hunk)) {
- /* move the chain link to the chain out */
+ /* move the chain link to the output chain */
cl = ctx->in;
ctx->in = cl->next;
@@ -133,7 +138,7 @@ int ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
return rc;
}
- /* delete the completed hunk from the chain ctx->in */
+ /* delete the completed hunk from the ctx->in chain */
if (ngx_hunk_size(ctx->in->hunk) == 0) {
ctx->in = ctx->in->next;
@@ -157,6 +162,10 @@ int ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
ngx_chain_update_chains(&ctx->free, &ctx->busy, &out, ctx->tag);
last_out = &out;
+
+ if (last == NGX_ERROR) {
+ return last;
+ }
}
}