nginx-0.1.2-RELEASE import
*) 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; the bug had 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; the bug had 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.
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 6069847..74173d8 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1091,27 +1091,47 @@
name = r->virtual_names->elts;
for (i = 0; i < r->virtual_names->nelts; i++) {
- if (r->headers_in.host_name_len != name[i].name.len) {
- continue;
- }
- if (ngx_strncasecmp(r->headers_in.host->value.data,
- name[i].name.data,
- r->headers_in.host_name_len) == 0)
- {
- r->srv_conf = name[i].core_srv_conf->ctx->srv_conf;
- r->loc_conf = name[i].core_srv_conf->ctx->loc_conf;
- r->server_name = &name[i].name;
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "server name: %s", name[i].name.data);
- clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
- r->connection->log->file = clcf->err_log->file;
- if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION))
- {
- r->connection->log->log_level = clcf->err_log->log_level;
+ if (name[i].wildcard) {
+ if (r->headers_in.host_name_len <= name[i].name.len) {
+ continue;
}
- break;
+ if (ngx_rstrncasecmp(r->headers_in.host->value.data,
+ name[i].name.data,
+ name[i].name.len) == 0)
+ {
+ continue;
+ }
+
+ } else {
+ if (r->headers_in.host_name_len != name[i].name.len) {
+ continue;
+ }
+
+ if (ngx_strncasecmp(r->headers_in.host->value.data,
+ name[i].name.data,
+ name[i].name.len) != 0)
+ {
+ continue;
+ }
}
+
+ r->srv_conf = name[i].core_srv_conf->ctx->srv_conf;
+ r->loc_conf = name[i].core_srv_conf->ctx->loc_conf;
+ r->server_name = &name[i].name;
+
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+ r->connection->log->file = clcf->err_log->file;
+
+ if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
+ r->connection->log->log_level = clcf->err_log->log_level;
+ }
+
+ break;
}
if (i == r->virtual_names->nelts) {
@@ -1562,7 +1582,13 @@
if (b != c->buffer) {
- /* move the large header buffers to the free list */
+ /*
+ * If the large header buffers were allocated while the previous
+ * request processing then we do not use c->buffer for
+ * the pipelined request (see ngx_http_init_request()).
+ *
+ * Now we would move the large header buffers to the free list.
+ */
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
@@ -1614,6 +1640,14 @@
hc->pipeline = 0;
+ /*
+ * To keep a memory footprint as small as possible for an idle
+ * keepalive connection we try to free the ngx_http_request_t and
+ * c->buffer's memory if they were allocated outside the c->pool.
+ * The large header buffers are always allocated outside the c->pool and
+ * are freed too.
+ */
+
if (ngx_pfree(c->pool, r) == NGX_OK) {
hc->request = NULL;
}
@@ -1621,6 +1655,12 @@
b = c->buffer;
if (ngx_pfree(c->pool, b->start) == NGX_OK) {
+
+ /*
+ * the special note for ngx_http_keepalive_handler() that
+ * c->buffer's memory was freed
+ */
+
b->pos = NULL;
} else {
@@ -1655,7 +1695,7 @@
rev->event_handler = ngx_http_keepalive_handler;
if (wev->active) {
- if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
if (ngx_del_event(wev, NGX_WRITE_EVENT, NGX_DISABLE_EVENT)
== NGX_ERROR)
{
@@ -1702,7 +1742,7 @@
}
#if 0
- /* if "keepalive_buffers off" then we need some other place */
+ /* if ngx_http_request_t was freed then we need some other place */
r->http_state = NGX_HTTP_KEEPALIVE_STATE;
#endif
@@ -1734,7 +1774,7 @@
#if (HAVE_KQUEUE)
- if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
if (rev->pending_eof) {
ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno,
"kevent() reported that client %s closed "
@@ -1751,6 +1791,13 @@
size = b->end - b->start;
if (b->pos == NULL) {
+
+ /*
+ * The c->buffer's memory was freed by ngx_http_set_keepalive().
+ * However, the c->buffer->start and c->buffer->end were not changed
+ * to keep the buffer size.
+ */
+
if (!(b->pos = ngx_palloc(c->pool, size))) {
ngx_http_close_connection(c);
return;
@@ -1824,7 +1871,7 @@
wev->event_handler = ngx_http_empty_handler;
if (wev->active) {
- if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
if (ngx_del_event(wev, NGX_WRITE_EVENT, NGX_DISABLE_EVENT)
== NGX_ERROR)
{