2002-08-07 00:39:45 +08:00
|
|
|
|
2004-09-28 16:34:51 +08:00
|
|
|
/*
|
2004-09-30 00:00:49 +08:00
|
|
|
* Copyright (C) Igor Sysoev
|
2004-09-28 16:34:51 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-08-07 00:39:45 +08:00
|
|
|
#include <ngx_config.h>
|
2003-06-03 23:42:58 +08:00
|
|
|
#include <ngx_core.h>
|
2002-08-07 00:39:45 +08:00
|
|
|
|
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
static void *ngx_palloc_block(ngx_pool_t *pool, size_t size);
|
|
|
|
static void *ngx_palloc_large(ngx_pool_t *pool, size_t size);
|
|
|
|
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
ngx_pool_t *
|
|
|
|
ngx_create_pool(size_t size, ngx_log_t *log)
|
2002-08-07 00:39:45 +08:00
|
|
|
{
|
2003-11-21 14:30:49 +08:00
|
|
|
ngx_pool_t *p;
|
2002-08-07 00:39:45 +08:00
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
p = ngx_alloc(size, log);
|
|
|
|
if (p == NULL) {
|
2005-07-08 22:34:20 +08:00
|
|
|
return NULL;
|
2003-11-21 14:30:49 +08:00
|
|
|
}
|
2002-08-07 00:39:45 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
p->d.last = (u_char *) p + sizeof(ngx_pool_t);
|
|
|
|
p->d.end = (u_char *) p + size;
|
|
|
|
p->d.next = NULL;
|
|
|
|
|
2008-06-21 14:40:32 +08:00
|
|
|
size = size - sizeof(ngx_pool_t);
|
|
|
|
p->max = (size < NGX_MAX_ALLOC_FROM_POOL) ? size : NGX_MAX_ALLOC_FROM_POOL;
|
|
|
|
|
2005-11-26 18:11:11 +08:00
|
|
|
p->current = p;
|
|
|
|
p->chain = NULL;
|
2002-08-07 00:39:45 +08:00
|
|
|
p->large = NULL;
|
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
2005-05-12 22:58:06 +08:00
|
|
|
p->cleanup = NULL;
|
2002-08-07 00:39:45 +08:00
|
|
|
p->log = log;
|
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2003-10-23 14:13:16 +08:00
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
void
|
|
|
|
ngx_destroy_pool(ngx_pool_t *pool)
|
2002-08-07 00:39:45 +08:00
|
|
|
{
|
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
2005-05-12 22:58:06 +08:00
|
|
|
ngx_pool_t *p, *n;
|
|
|
|
ngx_pool_large_t *l;
|
|
|
|
ngx_pool_cleanup_t *c;
|
|
|
|
|
|
|
|
for (c = pool->cleanup; c; c = c->next) {
|
|
|
|
if (c->handler) {
|
2007-12-18 01:29:36 +08:00
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0,
|
|
|
|
"run cleanup: %p", c);
|
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
2005-05-12 22:58:06 +08:00
|
|
|
c->handler(c->data);
|
|
|
|
}
|
|
|
|
}
|
2002-08-07 00:39:45 +08:00
|
|
|
|
2002-09-11 23:18:33 +08:00
|
|
|
for (l = pool->large; l; l = l->next) {
|
2004-02-12 01:08:49 +08:00
|
|
|
|
2004-11-11 22:07:14 +08:00
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0, "free: %p", l->alloc);
|
2004-02-12 01:08:49 +08:00
|
|
|
|
2003-10-23 14:13:16 +08:00
|
|
|
if (l->alloc) {
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_free(l->alloc);
|
2003-10-23 14:13:16 +08:00
|
|
|
}
|
2002-09-11 23:18:33 +08:00
|
|
|
}
|
2002-08-07 00:39:45 +08:00
|
|
|
|
2004-02-12 01:08:49 +08:00
|
|
|
#if (NGX_DEBUG)
|
|
|
|
|
2003-08-08 23:13:24 +08:00
|
|
|
/*
|
2004-02-12 01:08:49 +08:00
|
|
|
* we could allocate the pool->log from this pool
|
|
|
|
* so we can not use this log while the free()ing the pool
|
2003-08-08 23:13:24 +08:00
|
|
|
*/
|
2003-08-06 22:43:50 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
for (p = pool, n = pool->d.next; /* void */; p = n, n = n->d.next) {
|
2004-09-23 14:32:00 +08:00
|
|
|
ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, pool->log, 0,
|
2008-06-17 23:00:30 +08:00
|
|
|
"free: %p, unused: %uz", p, p->d.end - p->d.last);
|
2003-09-25 03:51:12 +08:00
|
|
|
|
|
|
|
if (n == NULL) {
|
|
|
|
break;
|
|
|
|
}
|
2003-08-08 23:13:24 +08:00
|
|
|
}
|
2004-02-12 01:08:49 +08:00
|
|
|
|
2002-12-25 01:30:59 +08:00
|
|
|
#endif
|
2003-08-08 23:13:24 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
for (p = pool, n = pool->d.next; /* void */; p = n, n = n->d.next) {
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_free(p);
|
2003-08-08 23:13:24 +08:00
|
|
|
|
|
|
|
if (n == NULL) {
|
|
|
|
break;
|
|
|
|
}
|
2002-08-07 00:39:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-23 14:13:16 +08:00
|
|
|
|
2008-11-25 22:25:20 +08:00
|
|
|
void
|
|
|
|
ngx_reset_pool(ngx_pool_t *pool)
|
|
|
|
{
|
|
|
|
ngx_pool_t *p;
|
|
|
|
ngx_pool_large_t *l;
|
|
|
|
|
|
|
|
for (l = pool->large; l; l = l->next) {
|
|
|
|
if (l->alloc) {
|
|
|
|
ngx_free(l->alloc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pool->large = NULL;
|
|
|
|
|
|
|
|
for (p = pool; p; p = p->d.next) {
|
|
|
|
p->d.last = (u_char *) p + sizeof(ngx_pool_t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
void *
|
|
|
|
ngx_palloc(ngx_pool_t *pool, size_t size)
|
2002-08-07 00:39:45 +08:00
|
|
|
{
|
2008-06-17 23:00:30 +08:00
|
|
|
u_char *m;
|
|
|
|
ngx_pool_t *p;
|
2002-08-07 00:39:45 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
if (size <= pool->max) {
|
2006-12-19 04:46:49 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
p = pool->current;
|
2005-12-16 23:07:08 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
do {
|
|
|
|
m = ngx_align_ptr(p->d.last, NGX_ALIGNMENT);
|
2007-05-21 21:49:35 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
if ((size_t) (p->d.end - m) >= size) {
|
|
|
|
p->d.last = m + size;
|
2005-12-16 23:07:08 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
return m;
|
2005-12-16 23:07:08 +08:00
|
|
|
}
|
2003-06-12 13:54:39 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
p = p->d.next;
|
|
|
|
|
|
|
|
} while (p);
|
|
|
|
|
|
|
|
return ngx_palloc_block(pool, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ngx_palloc_large(pool, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void *
|
|
|
|
ngx_pnalloc(ngx_pool_t *pool, size_t size)
|
|
|
|
{
|
|
|
|
u_char *m;
|
|
|
|
ngx_pool_t *p;
|
|
|
|
|
|
|
|
if (size <= pool->max) {
|
|
|
|
|
|
|
|
p = pool->current;
|
|
|
|
|
|
|
|
do {
|
|
|
|
m = p->d.last;
|
|
|
|
|
|
|
|
if ((size_t) (p->d.end - m) >= size) {
|
|
|
|
p->d.last = m + size;
|
2002-08-07 00:39:45 +08:00
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
p = p->d.next;
|
2005-11-26 18:11:11 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
} while (p);
|
2006-12-19 04:46:49 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
return ngx_palloc_block(pool, size);
|
|
|
|
}
|
2002-08-07 00:39:45 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
return ngx_palloc_large(pool, size);
|
|
|
|
}
|
2003-10-23 14:13:16 +08:00
|
|
|
|
2003-11-21 14:30:49 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
static void *
|
|
|
|
ngx_palloc_block(ngx_pool_t *pool, size_t size)
|
|
|
|
{
|
|
|
|
u_char *m;
|
2008-06-21 04:57:40 +08:00
|
|
|
size_t psize;
|
2008-06-17 23:00:30 +08:00
|
|
|
ngx_pool_t *p, *new, *current;
|
2005-11-26 18:11:11 +08:00
|
|
|
|
2008-06-21 04:57:40 +08:00
|
|
|
psize = (size_t) (pool->d.end - (u_char *) pool);
|
|
|
|
|
2008-06-21 05:06:53 +08:00
|
|
|
m = ngx_alloc(psize, pool->log);
|
|
|
|
if (m == NULL) {
|
2008-06-17 23:00:30 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-10-23 14:13:16 +08:00
|
|
|
|
2008-06-21 05:06:53 +08:00
|
|
|
new = (ngx_pool_t *) m;
|
|
|
|
|
|
|
|
new->d.end = m + psize;
|
2008-06-21 04:57:40 +08:00
|
|
|
new->d.next = NULL;
|
|
|
|
|
2008-06-21 05:06:53 +08:00
|
|
|
m += sizeof(ngx_pool_data_t);
|
2008-11-07 00:14:24 +08:00
|
|
|
m = ngx_align_ptr(m, NGX_ALIGNMENT);
|
2008-06-21 05:06:53 +08:00
|
|
|
new->d.last = m + size;
|
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
current = pool->current;
|
|
|
|
|
|
|
|
for (p = current; p->d.next; p = p->d.next) {
|
|
|
|
if ((size_t) (p->d.end - p->d.last) < NGX_ALIGNMENT) {
|
|
|
|
current = p->d.next;
|
|
|
|
}
|
2003-10-23 14:13:16 +08:00
|
|
|
}
|
2002-08-07 00:39:45 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
p->d.next = new;
|
|
|
|
|
|
|
|
pool->current = current ? current : new;
|
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void *
|
|
|
|
ngx_palloc_large(ngx_pool_t *pool, size_t size)
|
|
|
|
{
|
|
|
|
void *p;
|
|
|
|
ngx_pool_large_t *large;
|
|
|
|
|
2008-07-30 20:34:04 +08:00
|
|
|
p = ngx_alloc(size, pool->log);
|
2005-03-19 20:38:37 +08:00
|
|
|
if (p == NULL) {
|
2003-11-21 14:30:49 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2008-07-30 20:34:04 +08:00
|
|
|
|
|
|
|
large = ngx_palloc(pool, sizeof(ngx_pool_large_t));
|
|
|
|
if (large == NULL) {
|
|
|
|
ngx_free(p);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
large->alloc = p;
|
|
|
|
large->next = pool->large;
|
|
|
|
pool->large = large;
|
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void *
|
|
|
|
ngx_pmemalign(ngx_pool_t *pool, size_t size, size_t alignment)
|
|
|
|
{
|
|
|
|
void *p;
|
|
|
|
ngx_pool_large_t *large;
|
|
|
|
|
|
|
|
p = ngx_memalign(alignment, size, pool->log);
|
2005-03-19 20:38:37 +08:00
|
|
|
if (p == NULL) {
|
2004-06-09 00:26:37 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2002-08-07 00:39:45 +08:00
|
|
|
|
2006-04-05 21:40:54 +08:00
|
|
|
large = ngx_palloc(pool, sizeof(ngx_pool_large_t));
|
|
|
|
if (large == NULL) {
|
2007-07-20 03:07:13 +08:00
|
|
|
ngx_free(p);
|
2006-04-05 21:40:54 +08:00
|
|
|
return NULL;
|
2003-10-23 14:13:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
large->alloc = p;
|
2006-04-05 21:40:54 +08:00
|
|
|
large->next = pool->large;
|
|
|
|
pool->large = large;
|
2002-08-07 00:39:45 +08:00
|
|
|
|
2003-10-23 14:13:16 +08:00
|
|
|
return p;
|
|
|
|
}
|
2002-08-07 00:39:45 +08:00
|
|
|
|
2003-10-23 14:13:16 +08:00
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
ngx_int_t
|
|
|
|
ngx_pfree(ngx_pool_t *pool, void *p)
|
2003-10-23 14:13:16 +08:00
|
|
|
{
|
|
|
|
ngx_pool_large_t *l;
|
|
|
|
|
|
|
|
for (l = pool->large; l; l = l->next) {
|
|
|
|
if (p == l->alloc) {
|
2004-02-12 01:08:49 +08:00
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0,
|
2004-11-11 22:07:14 +08:00
|
|
|
"free: %p", l->alloc);
|
2004-12-21 20:30:30 +08:00
|
|
|
ngx_free(l->alloc);
|
2003-10-23 14:13:16 +08:00
|
|
|
l->alloc = NULL;
|
2004-09-23 14:32:00 +08:00
|
|
|
|
|
|
|
return NGX_OK;
|
2003-10-23 14:13:16 +08:00
|
|
|
}
|
2002-08-07 00:39:45 +08:00
|
|
|
}
|
2004-09-23 14:32:00 +08:00
|
|
|
|
|
|
|
return NGX_DECLINED;
|
2002-08-07 00:39:45 +08:00
|
|
|
}
|
|
|
|
|
2003-10-23 14:13:16 +08:00
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
void *
|
|
|
|
ngx_pcalloc(ngx_pool_t *pool, size_t size)
|
2002-08-07 00:39:45 +08:00
|
|
|
{
|
|
|
|
void *p;
|
|
|
|
|
|
|
|
p = ngx_palloc(pool, size);
|
2002-12-25 01:30:59 +08:00
|
|
|
if (p) {
|
2002-08-07 00:39:45 +08:00
|
|
|
ngx_memzero(p, size);
|
2002-12-25 01:30:59 +08:00
|
|
|
}
|
2002-08-07 00:39:45 +08:00
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
2004-06-07 03:49:18 +08:00
|
|
|
|
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
2005-05-12 22:58:06 +08:00
|
|
|
|
|
|
|
ngx_pool_cleanup_t *
|
2005-10-19 20:33:58 +08:00
|
|
|
ngx_pool_cleanup_add(ngx_pool_t *p, size_t size)
|
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
2005-05-12 22:58:06 +08:00
|
|
|
{
|
|
|
|
ngx_pool_cleanup_t *c;
|
|
|
|
|
|
|
|
c = ngx_palloc(p, sizeof(ngx_pool_cleanup_t));
|
|
|
|
if (c == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-10-19 20:33:58 +08:00
|
|
|
if (size) {
|
|
|
|
c->data = ngx_palloc(p, size);
|
|
|
|
if (c->data == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
c->data = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
c->handler = NULL;
|
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
2005-05-12 22:58:06 +08:00
|
|
|
c->next = p->cleanup;
|
|
|
|
|
|
|
|
p->cleanup = c;
|
|
|
|
|
2005-10-19 20:33:58 +08:00
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, p->log, 0, "add cleanup: %p", c);
|
|
|
|
|
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
2005-05-12 22:58:06 +08:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ngx_pool_cleanup_file(void *data)
|
|
|
|
{
|
|
|
|
ngx_pool_cleanup_file_t *c = data;
|
|
|
|
|
2007-12-18 01:29:36 +08:00
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, c->log, 0, "file cleanup: fd:%d",
|
|
|
|
c->fd);
|
2005-10-19 20:33:58 +08:00
|
|
|
|
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
2005-05-12 22:58:06 +08:00
|
|
|
if (ngx_close_file(c->fd) == NGX_FILE_ERROR) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
|
|
|
|
ngx_close_file_n " \"%s\" failed", c->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-25 16:45:04 +08:00
|
|
|
void
|
|
|
|
ngx_pool_delete_file(void *data)
|
|
|
|
{
|
|
|
|
ngx_pool_cleanup_file_t *c = data;
|
|
|
|
|
|
|
|
ngx_err_t err;
|
|
|
|
|
2007-12-18 01:29:36 +08:00
|
|
|
ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, c->log, 0, "file cleanup: fd:%d %s",
|
|
|
|
c->fd, c->name);
|
2007-01-25 16:45:04 +08:00
|
|
|
|
|
|
|
if (ngx_delete_file(c->name) == NGX_FILE_ERROR) {
|
|
|
|
err = ngx_errno;
|
|
|
|
|
|
|
|
if (err != NGX_ENOENT) {
|
|
|
|
ngx_log_error(NGX_LOG_CRIT, c->log, err,
|
|
|
|
ngx_delete_file_n " \"%s\" failed", c->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_close_file(c->fd) == NGX_FILE_ERROR) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
|
|
|
|
ngx_close_file_n " \"%s\" failed", c->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-07 03:49:18 +08:00
|
|
|
#if 0
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
static void *
|
|
|
|
ngx_get_cached_block(size_t size)
|
2004-06-07 03:49:18 +08:00
|
|
|
{
|
|
|
|
void *p;
|
|
|
|
ngx_cached_block_slot_t *slot;
|
|
|
|
|
|
|
|
if (ngx_cycle->cache == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
slot = &ngx_cycle->cache[(size + ngx_pagesize - 1) / ngx_pagesize];
|
|
|
|
|
|
|
|
slot->tries++;
|
|
|
|
|
|
|
|
if (slot->number) {
|
|
|
|
p = slot->block;
|
|
|
|
slot->block = slot->block->next;
|
|
|
|
slot->number--;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|