nginx-0.0.1-2003-07-21-01:15:59 import
diff --git a/src/http/modules/ngx_http_charset_filter.c b/src/http/modules/ngx_http_charset_filter.c
index 50642ef..ecc66b4 100644
--- a/src/http/modules/ngx_http_charset_filter.c
+++ b/src/http/modules/ngx_http_charset_filter.c
@@ -10,8 +10,8 @@
static int ngx_http_charset_filter_init(ngx_cycle_t *cycle);
-static void *ngx_http_charset_create_loc_conf(ngx_pool_t *pool);
-static char *ngx_http_charset_merge_loc_conf(ngx_pool_t *pool,
+static void *ngx_http_charset_create_loc_conf(ngx_conf_t *cf);
+static char *ngx_http_charset_merge_loc_conf(ngx_conf_t *cf,
void *parent, void *child);
@@ -100,19 +100,19 @@
}
-static void *ngx_http_charset_create_loc_conf(ngx_pool_t *pool)
+static void *ngx_http_charset_create_loc_conf(ngx_conf_t *cf)
{
ngx_http_charset_loc_conf_t *lcf;
ngx_test_null(lcf,
- ngx_pcalloc(pool, sizeof(ngx_http_charset_loc_conf_t)),
+ ngx_pcalloc(cf->pool, sizeof(ngx_http_charset_loc_conf_t)),
NGX_CONF_ERROR);
return lcf;
}
-static char *ngx_http_charset_merge_loc_conf(ngx_pool_t *pool,
+static char *ngx_http_charset_merge_loc_conf(ngx_conf_t *cf,
void *parent, void *child)
{
ngx_http_charset_loc_conf_t *prev = parent;
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c
index c6c1117..7c348e2 100644
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -15,11 +15,11 @@
static int ngx_http_index_test_dir(ngx_http_request_t *r);
static int ngx_http_index_init(ngx_cycle_t *cycle);
-static void *ngx_http_index_create_conf(ngx_pool_t *pool);
-static char *ngx_http_index_merge_conf(ngx_pool_t *p, void *parent,
- void *child);
+static void *ngx_http_index_create_conf(ngx_conf_t *cf);
+static char *ngx_http_index_merge_conf(ngx_conf_t *cf,
+ void *parent, void *child);
static char *ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd,
- void *conf);
+ void *conf);
static ngx_command_t ngx_http_index_commands[] = {
@@ -220,14 +220,15 @@
}
-static void *ngx_http_index_create_conf(ngx_pool_t *pool)
+static void *ngx_http_index_create_conf(ngx_conf_t *cf)
{
ngx_http_index_conf_t *conf;
- ngx_test_null(conf, ngx_palloc(pool, sizeof(ngx_http_index_conf_t)),
+ ngx_test_null(conf, ngx_palloc(cf->pool, sizeof(ngx_http_index_conf_t)),
NGX_CONF_ERROR);
- ngx_init_array(conf->indices, pool, 3, sizeof(ngx_str_t), NGX_CONF_ERROR);
+ ngx_init_array(conf->indices, cf->pool, 3, sizeof(ngx_str_t),
+ NGX_CONF_ERROR);
conf->max_index_len = 0;
return conf;
@@ -236,7 +237,8 @@
/* TODO: remove duplicate indices */
-static char *ngx_http_index_merge_conf(ngx_pool_t *p, void *parent, void *child)
+static char *ngx_http_index_merge_conf(ngx_conf_t *cf,
+ void *parent, void *child)
{
ngx_http_index_conf_t *prev = parent;
ngx_http_index_conf_t *conf = child;
diff --git a/src/http/modules/ngx_http_log_handler.c b/src/http/modules/ngx_http_log_handler.c
index c186ac9..759ac76 100644
--- a/src/http/modules/ngx_http_log_handler.c
+++ b/src/http/modules/ngx_http_log_handler.c
@@ -5,14 +5,14 @@
typedef struct {
- ngx_file_t file;
+ ngx_open_file_t *file;
} ngx_http_log_conf_t;
-static void *ngx_http_log_create_conf(ngx_pool_t *pool);
-static char *ngx_http_log_merge_conf(ngx_pool_t *p, void *parent, void *child);
+static void *ngx_http_log_create_conf(ngx_conf_t *cf);
+static char *ngx_http_log_merge_conf(ngx_conf_t *cf, void *parent, void *child);
static char *ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd,
- void *conf);
+ void *conf);
static ngx_command_t ngx_http_log_commands[] = {
@@ -49,6 +49,8 @@
};
+static ngx_str_t http_access_log = ngx_string("access.log");
+
static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
@@ -60,6 +62,9 @@
size_t len;
ngx_tm_t tm;
ngx_http_log_conf_t *lcf;
+#if (WIN32)
+ int written;
+#endif
ngx_log_debug(r->connection->log, "log handler");
@@ -135,35 +140,47 @@
*p++ = '"';
#if (WIN32)
+
*p++ = CR; *p++ = LF;
+ WriteFile(lcf->file->fd, line, p - line, &written, NULL);
+
#else
+
*p++ = LF;
+ write(lcf->file->fd, line, p - line);
+
#endif
- write(lcf->file.fd, line, p - line);
return NGX_OK;
}
-static void *ngx_http_log_create_conf(ngx_pool_t *pool)
+static void *ngx_http_log_create_conf(ngx_conf_t *cf)
{
ngx_http_log_conf_t *conf;
- ngx_test_null(conf, ngx_pcalloc(pool, sizeof(ngx_http_log_conf_t)),
+ ngx_test_null(conf, ngx_pcalloc(cf->pool, sizeof(ngx_http_log_conf_t)),
NGX_CONF_ERROR);
return conf;
}
-static char *ngx_http_log_merge_conf(ngx_pool_t *p, void *parent, void *child)
+static char *ngx_http_log_merge_conf(ngx_conf_t *cf, void *parent, void *child)
{
ngx_http_log_conf_t *prev = parent;
ngx_http_log_conf_t *conf = child;
- /* STUB */
- *conf = *prev;
+ if (conf->file == NULL) {
+ if (prev->file) {
+ conf->file = prev->file;
+ } else {
+ ngx_test_null(conf->file,
+ ngx_conf_open_file(cf->cycle, &http_access_log),
+ NGX_CONF_ERROR);
+ }
+ }
return NGX_CONF_OK;
}
@@ -174,44 +191,12 @@
{
ngx_http_log_conf_t *lcf = conf;
- int len;
- ngx_err_t err;
ngx_str_t *value;
value = cf->args->elts;
- lcf->file.name.len = value[1].len;
- lcf->file.name.data = value[1].data;
-
- lcf->file.fd = ngx_open_file(lcf->file.name.data,
- NGX_FILE_RDWR,
- NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
-
- if (lcf->file.fd == NGX_INVALID_FILE) {
- err = ngx_errno;
- len = ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
- ngx_open_file_n " \"%s\" failed (%d: ",
- lcf->file.name.data, err);
- len += ngx_strerror_r(err, ngx_conf_errstr + len,
- sizeof(ngx_conf_errstr) - len - 1);
- ngx_conf_errstr[len++] = ')';
- ngx_conf_errstr[len++] = '\0';
- return ngx_conf_errstr;
- }
-
-#if (WIN32)
- if (ngx_file_append_mode(lcf->file.fd) == NGX_ERROR) {
- err = ngx_errno;
- len = ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1,
- ngx_file_append_mode_n " \"%s\" failed (%d: ",
- lcf->file.name.data, err);
- len += ngx_strerror_r(err, ngx_conf_errstr + len,
- sizeof(ngx_conf_errstr) - len - 1);
- ngx_conf_errstr[len++] = ')';
- ngx_conf_errstr[len++] = '\0';
- return ngx_conf_errstr;
- }
-#endif
+ ngx_test_null(lcf->file, ngx_conf_open_file(cf->cycle, &value[1]),
+ NGX_CONF_ERROR);
return NGX_CONF_OK;
}
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
index 9455026..551a1e8 100644
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -56,7 +56,7 @@
ngx_http_in_addr_t *in_addr, *inaddr;
ngx_http_core_main_conf_t *cmcf;
ngx_http_core_srv_conf_t **cscfp, *cscf;
- ngx_http_core_loc_conf_t **clcfp;
+ ngx_http_core_loc_conf_t **clcfp, *clcf;
ngx_http_listen_t *lscf;
ngx_http_server_name_t *s_name, *name;
#if (WIN32)
@@ -108,20 +108,17 @@
mi = ngx_modules[m]->ctx_index;
if (module->create_main_conf) {
- ngx_test_null(ctx->main_conf[mi],
- module->create_main_conf(cf->pool),
+ ngx_test_null(ctx->main_conf[mi], module->create_main_conf(cf),
NGX_CONF_ERROR);
}
if (module->create_srv_conf) {
- ngx_test_null(ctx->srv_conf[mi],
- module->create_srv_conf(cf->pool),
+ ngx_test_null(ctx->srv_conf[mi], module->create_srv_conf(cf),
NGX_CONF_ERROR);
}
if (module->create_loc_conf) {
- ngx_test_null(ctx->loc_conf[mi],
- module->create_loc_conf(cf->pool),
+ ngx_test_null(ctx->loc_conf[mi], module->create_loc_conf(cf),
NGX_CONF_ERROR);
}
}
@@ -157,7 +154,7 @@
/* init http{} main_conf's */
if (module->init_main_conf) {
- rv = module->init_main_conf(cf->pool, ctx->main_conf[mi]);
+ rv = module->init_main_conf(cf, ctx->main_conf[mi]);
if (rv != NGX_CONF_OK) {
return rv;
}
@@ -168,7 +165,7 @@
/* merge the server{}s' srv_conf's */
if (module->merge_srv_conf) {
- rv = module->merge_srv_conf(cf->pool,
+ rv = module->merge_srv_conf(cf,
ctx->srv_conf[mi],
cscfp[s]->ctx->srv_conf[mi]);
if (rv != NGX_CONF_OK) {
@@ -180,7 +177,7 @@
/* merge the server{}'s loc_conf */
- rv = module->merge_loc_conf(cf->pool,
+ rv = module->merge_loc_conf(cf,
ctx->loc_conf[mi],
cscfp[s]->ctx->loc_conf[mi]);
if (rv != NGX_CONF_OK) {
@@ -192,7 +189,7 @@
clcfp = (ngx_http_core_loc_conf_t **)cscfp[s]->locations.elts;
for (l = 0; l < cscfp[s]->locations.nelts; l++) {
- rv = module->merge_loc_conf(cf->pool,
+ rv = module->merge_loc_conf(cf,
cscfp[s]->ctx->loc_conf[mi],
clcfp[l]->loc_conf[mi]);
if (rv != NGX_CONF_OK) {
@@ -464,12 +461,18 @@
ls->nonblocking = 1;
ls->handler = ngx_http_init_connection;
+
+#if 0
ls->log = cf->cycle->log;
+#endif
cscf = in_addr[a].core_srv_conf;
ls->pool_size = cscf->connection_pool_size;
ls->post_accept_timeout = cscf->post_accept_timeout;
+ clcf = cscf->ctx->loc_conf[ngx_http_core_module.ctx_index];
+ ls->log = clcf->err_log;
+
#if (WIN32)
iocpcf = ngx_event_get_conf(cf->cycle->conf_ctx, ngx_iocp_module);
if (iocpcf->acceptex_read) {
diff --git a/src/http/ngx_http_config.h b/src/http/ngx_http_config.h
index 50804c3..9d200c4 100644
--- a/src/http/ngx_http_config.h
+++ b/src/http/ngx_http_config.h
@@ -20,14 +20,14 @@
typedef struct {
- void *(*create_main_conf)(ngx_pool_t *p);
- char *(*init_main_conf)(ngx_pool_t *p, void *conf);
+ void *(*create_main_conf)(ngx_conf_t *cf);
+ char *(*init_main_conf)(ngx_conf_t *cf, void *conf);
- void *(*create_srv_conf)(ngx_pool_t *p);
- char *(*merge_srv_conf)(ngx_pool_t *p, void *prev, void *conf);
+ void *(*create_srv_conf)(ngx_conf_t *cf);
+ char *(*merge_srv_conf)(ngx_conf_t *cf, void *prev, void *conf);
- void *(*create_loc_conf)(ngx_pool_t *p);
- char *(*merge_loc_conf)(ngx_pool_t *p, void *prev, void *conf);
+ void *(*create_loc_conf)(ngx_conf_t *cf);
+ char *(*merge_loc_conf)(ngx_conf_t *cf, void *prev, void *conf);
} ngx_http_module_t;
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index aa3c582..a895fbd 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -11,25 +11,26 @@
static int ngx_http_core_index_handler(ngx_http_request_t *r);
-static void *ngx_http_core_create_main_conf(ngx_pool_t *pool);
-static char *ngx_http_core_init_main_conf(ngx_pool_t *pool, void *conf);
-static void *ngx_http_core_create_srv_conf(ngx_pool_t *pool);
-static char *ngx_http_core_merge_srv_conf(ngx_pool_t *pool,
+static void *ngx_http_core_create_main_conf(ngx_conf_t *cf);
+static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf);
+static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf);
+static char *ngx_http_core_merge_srv_conf(ngx_conf_t *cf,
void *parent, void *child);
-static void *ngx_http_core_create_loc_conf(ngx_pool_t *pool);
-static char *ngx_http_core_merge_loc_conf(ngx_pool_t *pool,
+static void *ngx_http_core_create_loc_conf(ngx_conf_t *cf);
+static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
void *parent, void *child);
static int ngx_http_core_init(ngx_cycle_t *cycle);
static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy);
static int ngx_cmp_locations(const void *first, const void *second);
static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd,
- void *dummy);
+ void *dummy);
static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf);
static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd,
- void *conf);
+ void *conf);
+static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static ngx_command_t ngx_http_core_commands[] = {
@@ -165,6 +166,13 @@
offsetof(ngx_http_core_loc_conf_t, lingering_timeout),
NULL},
+ {ngx_string("error_log"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_set_error_log,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ 0,
+ NULL},
+
ngx_null_command
};
@@ -226,22 +234,25 @@
#if 0
ngx_log_debug(r->connection->log, "trans: %s" _ clcfp[i]->name.data);
#endif
- if (r->uri.len < clcfp[i]->name.len) {
- continue;
- }
+ if (r->uri.len < clcfp[i]->name.len) {
+ continue;
+ }
- rc = ngx_strncmp(r->uri.data, clcfp[i]->name.data,
- clcfp[i]->name.len);
+ rc = ngx_strncmp(r->uri.data, clcfp[i]->name.data,
+ clcfp[i]->name.len);
ngx_log_debug(r->connection->log, "rc: %d" _ rc);
- if (rc < 0) {
- break;
- }
+ if (rc < 0) {
+ break;
+ }
- if (rc == 0) {
- r->loc_conf = clcfp[i]->loc_conf;
- }
+ if (rc == 0) {
+ r->loc_conf = clcfp[i]->loc_conf;
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+ r->connection->log->file = clcf->err_log->file;
+ r->connection->log->log_level = clcf->err_log->log_level;
+ }
}
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
@@ -583,13 +594,13 @@
if (module->create_srv_conf) {
ngx_test_null(ctx->srv_conf[ngx_modules[m]->ctx_index],
- module->create_srv_conf(cf->pool),
+ module->create_srv_conf(cf),
NGX_CONF_ERROR);
}
if (module->create_loc_conf) {
ngx_test_null(ctx->loc_conf[ngx_modules[m]->ctx_index],
- module->create_loc_conf(cf->pool),
+ module->create_loc_conf(cf),
NGX_CONF_ERROR);
}
}
@@ -664,7 +675,7 @@
if (module->create_loc_conf) {
ngx_test_null(ctx->loc_conf[ngx_modules[m]->ctx_index],
- module->create_loc_conf(cf->pool),
+ module->create_loc_conf(cf),
NGX_CONF_ERROR);
}
}
@@ -740,22 +751,23 @@
}
-static void *ngx_http_core_create_main_conf(ngx_pool_t *pool)
+static void *ngx_http_core_create_main_conf(ngx_conf_t *cf)
{
ngx_http_core_main_conf_t *cmcf;
ngx_test_null(cmcf,
- ngx_palloc(pool, sizeof(ngx_http_core_main_conf_t)),
+ ngx_palloc(cf->pool, sizeof(ngx_http_core_main_conf_t)),
NGX_CONF_ERROR);
- ngx_init_array(cmcf->servers, pool, 5, sizeof(ngx_http_core_srv_conf_t *),
+ ngx_init_array(cmcf->servers, cf->pool,
+ 5, sizeof(ngx_http_core_srv_conf_t *),
NGX_CONF_ERROR);
return cmcf;
}
-static char *ngx_http_core_init_main_conf(ngx_pool_t *pool, void *conf)
+static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf)
{
ngx_http_core_main_conf_t *cmcf = conf;
@@ -765,19 +777,20 @@
}
-static void *ngx_http_core_create_srv_conf(ngx_pool_t *pool)
+static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf)
{
ngx_http_core_srv_conf_t *cscf;
ngx_test_null(cscf,
- ngx_pcalloc(pool, sizeof(ngx_http_core_srv_conf_t)),
+ ngx_pcalloc(cf->pool, sizeof(ngx_http_core_srv_conf_t)),
NGX_CONF_ERROR);
- ngx_init_array(cscf->locations, pool, 5, sizeof(void *), NGX_CONF_ERROR);
- ngx_init_array(cscf->listen, pool, 5, sizeof(ngx_http_listen_t),
+ ngx_init_array(cscf->locations, cf->pool,
+ 5, sizeof(void *), NGX_CONF_ERROR);
+ ngx_init_array(cscf->listen, cf->pool, 5, sizeof(ngx_http_listen_t),
NGX_CONF_ERROR);
- ngx_init_array(cscf->server_names, pool, 5, sizeof(ngx_http_server_name_t),
- NGX_CONF_ERROR);
+ ngx_init_array(cscf->server_names, cf->pool,
+ 5, sizeof(ngx_http_server_name_t), NGX_CONF_ERROR);
cscf->connection_pool_size = NGX_CONF_UNSET;
cscf->post_accept_timeout = NGX_CONF_UNSET;
@@ -790,14 +803,12 @@
}
-static char *ngx_http_core_merge_srv_conf(ngx_pool_t *pool,
+static char *ngx_http_core_merge_srv_conf(ngx_conf_t *cf,
void *parent, void *child)
{
ngx_http_core_srv_conf_t *prev = parent;
ngx_http_core_srv_conf_t *conf = child;
- int len;
- ngx_err_t err;
ngx_http_listen_t *l;
ngx_http_server_name_t *n;
@@ -817,24 +828,13 @@
if (conf->server_names.nelts == 0) {
ngx_test_null(n, ngx_push_array(&conf->server_names), NGX_CONF_ERROR);
- ngx_test_null(n->name.data, ngx_palloc(pool, NGX_MAXHOSTNAMELEN),
+ ngx_test_null(n->name.data, ngx_palloc(cf->pool, NGX_MAXHOSTNAMELEN),
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);
- len += ngx_strerror_r(err, ngx_conf_errstr + len,
- sizeof(ngx_conf_errstr) - len - 1);
- ngx_conf_errstr[len++] = ')';
- ngx_conf_errstr[len++] = '\0';
- return ngx_conf_errstr;
}
n->name.len = ngx_strlen(n->name.data);
@@ -858,12 +858,12 @@
}
-static void *ngx_http_core_create_loc_conf(ngx_pool_t *pool)
+static void *ngx_http_core_create_loc_conf(ngx_conf_t *cf)
{
ngx_http_core_loc_conf_t *lcf;
ngx_test_null(lcf,
- ngx_pcalloc(pool, sizeof(ngx_http_core_loc_conf_t)),
+ ngx_pcalloc(cf->pool, sizeof(ngx_http_core_loc_conf_t)),
NGX_CONF_ERROR);
/* set by ngx_pcalloc():
@@ -897,7 +897,7 @@
};
-static char *ngx_http_core_merge_loc_conf(ngx_pool_t *pool,
+static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
void *parent, void *child)
{
ngx_http_core_loc_conf_t *prev = parent;
@@ -914,13 +914,13 @@
} else {
ngx_test_null(conf->types,
- ngx_palloc(pool, NGX_HTTP_TYPES_HASH_PRIME
+ ngx_palloc(cf->pool, NGX_HTTP_TYPES_HASH_PRIME
* sizeof(ngx_array_t)),
NGX_CONF_ERROR);
for (i = 0; i < NGX_HTTP_TYPES_HASH_PRIME; i++) {
- ngx_init_array(conf->types[i], pool, 5, sizeof(ngx_http_type_t),
- NGX_CONF_ERROR);
+ ngx_init_array(conf->types[i], cf->pool,
+ 5, sizeof(ngx_http_type_t), NGX_CONF_ERROR);
}
for (i = 0; default_types[i].exten.len; i++) {
@@ -936,6 +936,14 @@
}
}
+ if (conf->err_log == NULL) {
+ if (prev->err_log) {
+ conf->err_log = prev->err_log;
+ } else {
+ conf->err_log = cf->cycle->log;
+ }
+ }
+
ngx_conf_merge_str_value(conf->default_type,
prev->default_type, "text/plain");
diff --git a/src/http/ngx_http_event.c b/src/http/ngx_http_event.c
index 5531bac..e129a6d 100644
--- a/src/http/ngx_http_event.c
+++ b/src/http/ngx_http_event.c
@@ -65,7 +65,7 @@
{
int event;
ngx_event_t *rev;
- ngx_http_log_ctx_t *lcx;
+ ngx_http_log_ctx_t *lctx;
c->addr_text.data = ngx_palloc(c->pool, c->listening->addr_text_max_len);
if (c->addr_text.data == NULL) {
@@ -81,15 +81,15 @@
return;
}
- lcx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t));
- if (lcx == NULL) {
+ lctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t));
+ if (lctx == NULL) {
ngx_http_close_connection(c);
return;
}
- lcx->client = c->addr_text.data;
- lcx->action = "reading client request line";
- c->log->data = lcx;
+ lctx->client = c->addr_text.data;
+ lctx->action = "reading client request line";
+ c->log->data = lctx;
c->log->handler = ngx_http_log_error;
rev = c->read;
@@ -136,6 +136,7 @@
ngx_http_in_addr_t *in_addr;
ngx_http_server_name_t *server_name;
ngx_http_core_srv_conf_t *cscf;
+ ngx_http_core_loc_conf_t *clcf;
c = rev->data;
@@ -212,6 +213,10 @@
server_name = cscf->server_names.elts;
r->server_name = &server_name->name;
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+ c->log->file = clcf->err_log->file;
+ c->log->log_level = clcf->err_log->log_level;
+
if (c->buffer == NULL) {
c->buffer = ngx_create_temp_hunk(c->pool,
cscf->client_header_buffer_size,
@@ -265,7 +270,7 @@
ssize_t n;
ngx_connection_t *c;
ngx_http_request_t *r;
- ngx_http_log_ctx_t *lcx;
+ ngx_http_log_ctx_t *lctx;
ngx_http_core_srv_conf_t *cscf;
c = rev->data;
@@ -421,9 +426,9 @@
return;
}
- lcx = c->log->data;
- lcx->action = "reading client request headers";
- lcx->url = r->unparsed_uri.data;
+ lctx = c->log->data;
+ lctx->action = "reading client request headers";
+ lctx->url = r->unparsed_uri.data;
r->headers_in.headers = ngx_create_table(r->pool, 10);
if (cscf->large_client_header
@@ -505,6 +510,7 @@
ngx_http_request_t *r;
ngx_http_server_name_t *name;
ngx_http_core_srv_conf_t *cscf;
+ ngx_http_core_loc_conf_t *clcf;
c = rev->data;
r = c->data;
@@ -619,6 +625,12 @@
{
r->srv_conf = name[i].core_srv_conf->ctx->srv_conf;
r->loc_conf = name[i].core_srv_conf->ctx->loc_conf;
+
+ clcf = ngx_http_get_module_loc_conf(r,
+ ngx_http_core_module);
+ c->log->file = clcf->err_log->file;
+ c->log->log_level = clcf->err_log->log_level;
+
break;
}
}
diff --git a/src/http/ngx_http_get_time.c b/src/http/ngx_http_get_time.c
index 45df008..971914e 100644
--- a/src/http/ngx_http_get_time.c
+++ b/src/http/ngx_http_get_time.c
@@ -5,7 +5,7 @@
size_t ngx_http_get_time(char *buf, time_t t)
{
- struct tm *tp;
+ struct tm *tp;
tp = gmtime(&t);
return strftime(buf, 30, "%a, %d %b %Y %H:%M:%S GMT", tp);
diff --git a/src/http/ngx_http_output_filter.c b/src/http/ngx_http_output_filter.c
index dbc56de..6e1d9d3 100644
--- a/src/http/ngx_http_output_filter.c
+++ b/src/http/ngx_http_output_filter.c
@@ -18,8 +18,8 @@
static int ngx_http_output_filter_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src);
-static void *ngx_http_output_filter_create_conf(ngx_pool_t *pool);
-static char *ngx_http_output_filter_merge_conf(ngx_pool_t *pool,
+static void *ngx_http_output_filter_create_conf(ngx_conf_t *cf);
+static char *ngx_http_output_filter_merge_conf(ngx_conf_t *cf,
void *parent, void *child);
@@ -307,12 +307,12 @@
}
-static void *ngx_http_output_filter_create_conf(ngx_pool_t *pool)
+static void *ngx_http_output_filter_create_conf(ngx_conf_t *cf)
{
ngx_http_output_filter_conf_t *conf;
ngx_test_null(conf,
- ngx_palloc(pool, sizeof(ngx_http_output_filter_conf_t)),
+ ngx_palloc(cf->pool, sizeof(ngx_http_output_filter_conf_t)),
NULL);
conf->hunk_size = NGX_CONF_UNSET;
@@ -321,7 +321,7 @@
}
-static char *ngx_http_output_filter_merge_conf(ngx_pool_t *pool,
+static char *ngx_http_output_filter_merge_conf(ngx_conf_t *cf,
void *parent, void *child)
{
ngx_http_output_filter_conf_t *prev = parent;
diff --git a/src/http/ngx_http_write_filter.c b/src/http/ngx_http_write_filter.c
index 1a9f928..26c632c 100644
--- a/src/http/ngx_http_write_filter.c
+++ b/src/http/ngx_http_write_filter.c
@@ -15,8 +15,8 @@
} ngx_http_write_filter_ctx_t;
-static void *ngx_http_write_filter_create_conf(ngx_pool_t *pool);
-static char *ngx_http_write_filter_merge_conf(ngx_pool_t *pool,
+static void *ngx_http_write_filter_create_conf(ngx_conf_t *cf);
+static char *ngx_http_write_filter_merge_conf(ngx_conf_t *cf,
void *parent, void *child);
static int ngx_http_write_filter_init(ngx_cycle_t *cycle);
@@ -162,12 +162,12 @@
}
-static void *ngx_http_write_filter_create_conf(ngx_pool_t *pool)
+static void *ngx_http_write_filter_create_conf(ngx_conf_t *cf)
{
ngx_http_write_filter_conf_t *conf;
ngx_test_null(conf,
- ngx_palloc(pool, sizeof(ngx_http_write_filter_conf_t)),
+ ngx_palloc(cf->pool, sizeof(ngx_http_write_filter_conf_t)),
NULL);
conf->buffer_output = NGX_CONF_UNSET;
@@ -176,7 +176,7 @@
}
-static char *ngx_http_write_filter_merge_conf(ngx_pool_t *pool,
+static char *ngx_http_write_filter_merge_conf(ngx_conf_t *cf,
void *parent, void *child)
{
ngx_http_write_filter_conf_t *prev = parent;