diff options
author | Igor Sysoev <igor@sysoev.ru> | 2005-05-12 14:58:06 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2005-05-12 14:58:06 +0000 |
commit | 899b44eab259f32af5c6e3da342f430c654528ce (patch) | |
tree | 23fb5dfbc9219030f9e102db5a2ce44e98c0a9d0 /src/core | |
parent | 22157ce9d570452b2d77f0fe7e510e6b0e4d05c2 (diff) | |
download | nginx-release-0.1.29.tar.gz nginx-release-0.1.29.zip |
nginx-0.1.29-RELEASE importrelease-0.1.29
*) 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.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/nginx.c | 2 | ||||
-rw-r--r-- | src/core/nginx.h | 2 | ||||
-rw-r--r-- | src/core/ngx_array.h | 13 | ||||
-rw-r--r-- | src/core/ngx_buf.c | 3 | ||||
-rw-r--r-- | src/core/ngx_buf.h | 5 | ||||
-rw-r--r-- | src/core/ngx_conf_file.c | 55 | ||||
-rw-r--r-- | src/core/ngx_conf_file.h | 8 | ||||
-rw-r--r-- | src/core/ngx_cycle.c | 2 | ||||
-rw-r--r-- | src/core/ngx_file.c | 20 | ||||
-rw-r--r-- | src/core/ngx_hash.c | 51 | ||||
-rw-r--r-- | src/core/ngx_hash.h | 3 | ||||
-rw-r--r-- | src/core/ngx_inet.c | 19 | ||||
-rw-r--r-- | src/core/ngx_log.c | 2 | ||||
-rw-r--r-- | src/core/ngx_output_chain.c | 9 | ||||
-rw-r--r-- | src/core/ngx_palloc.c | 45 | ||||
-rw-r--r-- | src/core/ngx_palloc.h | 41 | ||||
-rw-r--r-- | src/core/ngx_times.c | 3 | ||||
-rw-r--r-- | src/core/ngx_times.h | 1 | ||||
-rw-r--r-- | src/core/ngx_unix_domain.c | 4 |
19 files changed, 229 insertions, 59 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index 9f2211291..bb6f093e4 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -107,7 +107,7 @@ static ngx_core_module_t ngx_core_module_ctx = { ngx_module_t ngx_core_module = { - NGX_MODULE, + NGX_MODULE_V1, &ngx_core_module_ctx, /* module context */ ngx_core_commands, /* module directives */ NGX_CORE_MODULE, /* module type */ diff --git a/src/core/nginx.h b/src/core/nginx.h index 9fa141ab7..4d27a875f 100644 --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -8,7 +8,7 @@ #define _NGINX_H_INCLUDED_ -#define NGINX_VER "nginx/0.1.28" +#define NGINX_VER "nginx/0.1.29" #define NGINX_VAR "NGINX" #define NGX_NEWPID_EXT ".newbin" diff --git a/src/core/ngx_array.h b/src/core/ngx_array.h index 5f97451aa..00206cb1b 100644 --- a/src/core/ngx_array.h +++ b/src/core/ngx_array.h @@ -30,16 +30,21 @@ void *ngx_array_push_n(ngx_array_t *a, ngx_uint_t n); static ngx_inline ngx_int_t ngx_array_init(ngx_array_t *array, ngx_pool_t *pool, ngx_uint_t n, size_t size) { - array->elts = ngx_palloc(pool, n * size); - if (array->elts == NULL) { - return NGX_ERROR; - } + /* + * set "array->nelts" before "array->elts", otherwise MSVC thinks + * that "array->nelts" may be used without having been initialized + */ array->nelts = 0; array->size = size; array->nalloc = n; array->pool = pool; + array->elts = ngx_palloc(pool, n * size); + if (array->elts == NULL) { + return NGX_ERROR; + } + return NGX_OK; } diff --git a/src/core/ngx_buf.c b/src/core/ngx_buf.c index 4c1b1d5ac..b7f597d39 100644 --- a/src/core/ngx_buf.c +++ b/src/core/ngx_buf.c @@ -31,7 +31,7 @@ ngx_create_temp_buf(ngx_pool_t *pool, size_t size) * b->file = NULL; * b->shadow = NULL; * b->tag = 0; - * + * and flags */ b->pos = b->start; @@ -94,6 +94,7 @@ ngx_create_chain_of_bufs(ngx_pool_t *pool, ngx_bufs_t *bufs) * b->file = NULL; * b->shadow = NULL; * b->tag = 0; + * and flags * */ diff --git a/src/core/ngx_buf.h b/src/core/ngx_buf.h index 96394f9f6..471ab190c 100644 --- a/src/core/ngx_buf.h +++ b/src/core/ngx_buf.h @@ -44,7 +44,9 @@ struct ngx_buf_s { unsigned recycled:1; unsigned in_file:1; unsigned flush:1; + unsigned sync:1; unsigned last_buf:1; + unsigned last_in_chain:1; unsigned last_shadow:1; unsigned temp_file:1; @@ -104,7 +106,8 @@ typedef struct { #define ngx_buf_in_memory(b) (b->temporary || b->memory || b->mmap) #define ngx_buf_in_memory_only(b) (ngx_buf_in_memory(b) && !b->in_file) #define ngx_buf_special(b) \ - ((b->flush || b->last_buf) && !ngx_buf_in_memory(b) && !b->in_file) + ((b->flush || b->last_buf || b->sync) \ + && !ngx_buf_in_memory(b) && !b->in_file) #define ngx_buf_size(b) \ (ngx_buf_in_memory(b) ? (off_t) (b->last - b->pos): \ diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index 35ee8b8e0..b9b2200bf 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -27,7 +27,7 @@ static ngx_command_t ngx_conf_commands[] = { ngx_module_t ngx_conf_module = { - NGX_MODULE, + NGX_MODULE_V1, NULL, /* module context */ ngx_conf_commands, /* module directives */ NGX_CONF_MODULE, /* module type */ @@ -336,7 +336,7 @@ ngx_conf_read_token(ngx_conf_t *cf) { u_char *start, ch, *src, *dst; int len; - int found, need_space, last_space, sharp_comment; + int found, need_space, last_space, sharp_comment, variable; int quoted, s_quoted, d_quoted; ssize_t n; ngx_str_t *word; @@ -346,6 +346,7 @@ ngx_conf_read_token(ngx_conf_t *cf) need_space = 0; last_space = 1; sharp_comment = 0; + variable = 0; quoted = s_quoted = d_quoted = 0; cf->args->nelts = 0; @@ -492,11 +493,22 @@ ngx_conf_read_token(ngx_conf_t *cf) } } else { + if (ch == '{' && variable) { + continue; + } + + variable = 0; + if (ch == '\\') { quoted = 1; continue; } + if (ch == '$') { + variable = 1; + continue; + } + if (d_quoted) { if (ch == '"') { d_quoted = 0; @@ -802,6 +814,45 @@ ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) char * +ngx_conf_set_table_elt_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +{ + char *p = conf; + + ngx_str_t *value; + ngx_array_t **a; + ngx_table_elt_t *elt; + ngx_conf_post_t *post; + + a = (ngx_array_t **) (p + cmd->offset); + + if (*a == NULL) { + *a = ngx_array_create(cf->pool, 4, sizeof(ngx_table_elt_t)); + if (*a == NULL) { + return NGX_CONF_ERROR; + } + } + + elt = ngx_array_push(*a); + if (elt == NULL) { + return NGX_CONF_ERROR; + } + + value = cf->args->elts; + + elt->hash = 0; + elt->key = value[1]; + elt->value = value[2]; + + if (cmd->post) { + post = cmd->post; + return post->post_handler(cf, post, elt); + } + + return NGX_CONF_OK; +} + + +char * ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { char *p = conf; diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h index 4fab8c10c..899f046e8 100644 --- a/src/core/ngx_conf_file.h +++ b/src/core/ngx_conf_file.h @@ -63,7 +63,7 @@ #define NGX_CONF_BLOCK_DONE 2 #define NGX_CONF_FILE_DONE 3 -#define NGX_MODULE 0, 0 +#define NGX_MODULE_V1 0, 0, 1, 0, 0 #define NGX_CORE_MODULE 0x45524F43 /* "CORE" */ #define NGX_CONF_MODULE 0x464E4F43 /* "CONF" */ @@ -100,6 +100,10 @@ struct ngx_open_file_s { struct ngx_module_s { ngx_uint_t ctx_index; ngx_uint_t index; + ngx_uint_t version; + ngx_uint_t spare0; + ngx_uint_t spare1; + void *ctx; ngx_command_t *commands; ngx_uint_t type; @@ -280,6 +284,8 @@ void ngx_cdecl ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, 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_table_elt_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); char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c index 51042058a..eaebdb0bf 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c @@ -517,7 +517,7 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle) ngx_old_cycles.nalloc = n; ngx_old_cycles.pool = ngx_temp_pool; - ngx_cleaner_event.event_handler = ngx_clean_old_cycles; + ngx_cleaner_event.handler = ngx_clean_old_cycles; ngx_cleaner_event.log = cycle->log; ngx_cleaner_event.data = &dumb; dumb.fd = (ngx_socket_t) -1; diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c index 6fe04e70d..46d2e0acb 100644 --- a/src/core/ngx_file.c +++ b/src/core/ngx_file.c @@ -38,8 +38,10 @@ ngx_int_t ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path, ngx_pool_t *pool, int persistent) { - ngx_err_t err; - ngx_atomic_uint_t n; + ngx_err_t err; + ngx_atomic_uint_t n; + ngx_pool_cleanup_file_t *cln; + file->name.len = path->name.len + 1 + path->len + NGX_ATOMIC_T_LEN; @@ -74,6 +76,20 @@ ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path, ngx_pool_t *pool, "temp fd:%d", file->fd); if (file->fd != NGX_INVALID_FILE) { + cln = ngx_palloc(pool, sizeof(ngx_pool_cleanup_file_t)); + if (cln == NULL) { + return NGX_ERROR; + } + + cln->fd = file->fd; + cln->name = file->name.data; + cln->log = pool->log; + + if (ngx_pool_cleanup_add(pool, ngx_pool_cleanup_file, cln) == NULL) + { + return NGX_ERROR; + } + return NGX_OK; } diff --git a/src/core/ngx_hash.c b/src/core/ngx_hash.c index 2c062b709..6b75fa598 100644 --- a/src/core/ngx_hash.c +++ b/src/core/ngx_hash.c @@ -9,11 +9,20 @@ ngx_int_t -ngx_hash_init(ngx_hash_t *hash, ngx_pool_t *pool, void *names) +ngx_hash_init(ngx_hash_t *hash, ngx_pool_t *pool, void *names, ngx_uint_t nelts) { u_char *p; - ngx_str_t *n, *bucket; - ngx_uint_t i, key, size, best, *test, buckets, min_buckets; + ngx_str_t *name, *bucket; + ngx_uint_t i, n, key, size, best, *test, buckets, min_buckets; + + if (nelts == 0) { + for (name = (ngx_str_t *) names; + name->len; + name = (ngx_str_t *) ((char *) name + hash->bucket_size)) + { + nelts++; + } + } test = ngx_alloc(hash->max_size * sizeof(ngx_uint_t), pool->log); if (test == NULL) { @@ -34,14 +43,14 @@ ngx_hash_init(ngx_hash_t *hash, ngx_pool_t *pool, void *names) test[i] = 0; } - for (n = (ngx_str_t *) names; - n->len; - n = (ngx_str_t *) ((char *) n + hash->bucket_size)) + for (n = 0, name = (ngx_str_t *) names; + n < nelts; + n++, name = (ngx_str_t *) ((char *) name + hash->bucket_size)) { key = 0; - for (i = 0; i < n->len; i++) { - key += ngx_tolower(n->data[i]); + for (i = 0; i < name->len; i++) { + key += ngx_tolower(name->data[i]); } key %= size; @@ -57,7 +66,7 @@ ngx_hash_init(ngx_hash_t *hash, ngx_pool_t *pool, void *names) } } - if (n->len == 0) { + if (n == nelts) { if (min_buckets > buckets) { min_buckets = buckets; best = size; @@ -91,14 +100,14 @@ ngx_hash_init(ngx_hash_t *hash, ngx_pool_t *pool, void *names) test[i] = 0; } - for (n = (ngx_str_t *) names; - n->len; - n = (ngx_str_t *) ((char *) n + hash->bucket_size)) + for (n = 0, name = (ngx_str_t *) names; + n < nelts; + n++, name = (ngx_str_t *) ((char *) name + hash->bucket_size)) { key = 0; - for (i = 0; i < n->len; i++) { - key += ngx_tolower(n->data[i]); + for (i = 0; i < name->len; i++) { + key += ngx_tolower(name->data[i]); } key %= best; @@ -122,21 +131,21 @@ ngx_hash_init(ngx_hash_t *hash, ngx_pool_t *pool, void *names) } } - for (n = (ngx_str_t *) names; - n->len; - n = (ngx_str_t *) ((char *) n + hash->bucket_size)) + for (n = 0, name = (ngx_str_t *) names; + n < nelts; + n++, name = (ngx_str_t *) ((char *) name + hash->bucket_size)) { key = 0; - for (i = 0; i < n->len; i++) { - key += ngx_tolower(n->data[i]); + for (i = 0; i < name->len; i++) { + key += ngx_tolower(name->data[i]); } key %= best; if (hash->bucket_limit == 1) { p = (u_char *) hash->buckets + key * hash->bucket_size; - ngx_memcpy(p, n, hash->bucket_size); + ngx_memcpy(p, name, hash->bucket_size); continue; } @@ -147,7 +156,7 @@ ngx_hash_init(ngx_hash_t *hash, ngx_pool_t *pool, void *names) bucket->len &= 0x7fffffff; } - ngx_memcpy(bucket, n, hash->bucket_size); + ngx_memcpy(bucket, name, hash->bucket_size); bucket->len |= 0x80000000; } diff --git a/src/core/ngx_hash.h b/src/core/ngx_hash.h index 5a4bf5fbc..e9912579a 100644 --- a/src/core/ngx_hash.h +++ b/src/core/ngx_hash.h @@ -31,7 +31,8 @@ typedef struct { } ngx_table_elt_t; -ngx_int_t ngx_hash_init(ngx_hash_t *hash, ngx_pool_t *pool, void *names); +ngx_int_t ngx_hash_init(ngx_hash_t *hash, ngx_pool_t *pool, void *names, + ngx_uint_t nelts); #endif /* _NGX_HASH_H_INCLUDED_ */ diff --git a/src/core/ngx_inet.c b/src/core/ngx_inet.c index 6cad053b7..1ae7829fa 100644 --- a/src/core/ngx_inet.c +++ b/src/core/ngx_inet.c @@ -21,7 +21,8 @@ */ -static ngx_inline size_t ngx_sprint_uchar(u_char *text, u_char c, size_t len) +static +ngx_inline size_t ngx_sprint_uchar(u_char *text, u_char c, size_t len) { size_t n; ngx_uint_t c1, c2; @@ -65,8 +66,8 @@ static ngx_inline size_t ngx_sprint_uchar(u_char *text, u_char c, size_t len) /* AF_INET only */ -size_t ngx_sock_ntop(int family, struct sockaddr *sa, u_char *text, - size_t len) +size_t +ngx_sock_ntop(int family, struct sockaddr *sa, u_char *text, size_t len) { u_char *p; size_t n; @@ -119,7 +120,8 @@ size_t ngx_sock_ntop(int family, struct sockaddr *sa, u_char *text, return n; } -size_t ngx_inet_ntop(int family, void *addr, u_char *text, size_t len) +size_t +ngx_inet_ntop(int family, void *addr, u_char *text, size_t len) { u_char *p; size_t n; @@ -173,7 +175,8 @@ size_t ngx_inet_ntop(int family, void *addr, u_char *text, size_t len) /* AF_INET only */ -ngx_int_t ngx_ptocidr(ngx_str_t *text, void *cidr) +ngx_int_t +ngx_ptocidr(ngx_str_t *text, void *cidr) { ngx_int_t m; ngx_uint_t i; @@ -217,7 +220,8 @@ ngx_int_t ngx_ptocidr(ngx_str_t *text, void *cidr) } -ngx_peers_t *ngx_inet_upstream_parse(ngx_conf_t *cf, ngx_inet_upstream_t *u) +ngx_peers_t * +ngx_inet_upstream_parse(ngx_conf_t *cf, ngx_inet_upstream_t *u) { char *err; u_char *host; @@ -392,7 +396,8 @@ ngx_peers_t *ngx_inet_upstream_parse(ngx_conf_t *cf, ngx_inet_upstream_t *u) } -char *ngx_inet_parse_host_port(ngx_inet_upstream_t *u) +char * +ngx_inet_parse_host_port(ngx_inet_upstream_t *u) { size_t i; ngx_int_t port; diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c index 181d05928..278258262 100644 --- a/src/core/ngx_log.c +++ b/src/core/ngx_log.c @@ -33,7 +33,7 @@ static ngx_core_module_t ngx_errlog_module_ctx = { ngx_module_t ngx_errlog_module = { - NGX_MODULE, + NGX_MODULE_V1, &ngx_errlog_module_ctx, /* module context */ ngx_errlog_commands, /* module directives */ NGX_CORE_MODULE, /* module type */ diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c index fc8a0bf2a..e4a8723b2 100644 --- a/src/core/ngx_output_chain.c +++ b/src/core/ngx_output_chain.c @@ -49,7 +49,7 @@ ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in) #if (NGX_SENDFILE_LIMIT) && !(in->buf->in_file && in->buf->file_last > NGX_SENDFILE_LIMIT) #endif - && (!ngx_output_chain_need_to_copy(ctx, in->buf))) + && !ngx_output_chain_need_to_copy(ctx, in->buf)) { return ctx->output_filter(ctx->filter_ctx, in); } @@ -132,7 +132,7 @@ ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in) size = ctx->bufs.size; - if (ctx->in->buf->last_buf) { + if (ctx->in->buf->last_in_chain) { if (bsize < (off_t) ctx->bufs.size) { @@ -202,6 +202,11 @@ ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in) } if (out == NULL && last != NGX_NONE) { + + if (ctx->in) { + return NGX_AGAIN; + } + return last; } diff --git a/src/core/ngx_palloc.c b/src/core/ngx_palloc.c index 2804dd0ba..e7c888285 100644 --- a/src/core/ngx_palloc.c +++ b/src/core/ngx_palloc.c @@ -23,6 +23,7 @@ ngx_create_pool(size_t size, ngx_log_t *log) p->next = NULL; p->large = NULL; p->chain = NULL; + p->cleanup = NULL; p->log = log; return p; @@ -32,8 +33,15 @@ ngx_create_pool(size_t size, ngx_log_t *log) void ngx_destroy_pool(ngx_pool_t *pool) { - ngx_pool_t *p, *n; - ngx_pool_large_t *l; + 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) { + c->handler(c->data); + } + } for (l = pool->large; l; l = l->next) { @@ -197,6 +205,39 @@ ngx_pcalloc(ngx_pool_t *pool, size_t size) return p; } + +ngx_pool_cleanup_t * +ngx_pool_cleanup_add(ngx_pool_t *p, ngx_pool_cleanup_pt handler, void *data) +{ + ngx_pool_cleanup_t *c; + + c = ngx_palloc(p, sizeof(ngx_pool_cleanup_t)); + if (c == NULL) { + return NULL; + } + + c->handler = handler; + c->data = data; + c->next = p->cleanup; + + p->cleanup = c; + + return c; +} + + +void +ngx_pool_cleanup_file(void *data) +{ + ngx_pool_cleanup_file_t *c = data; + + 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); + } +} + + #if 0 static void * diff --git a/src/core/ngx_palloc.h b/src/core/ngx_palloc.h index bd256e8a9..62a571818 100644 --- a/src/core/ngx_palloc.h +++ b/src/core/ngx_palloc.h @@ -22,24 +22,44 @@ #define NGX_DEFAULT_POOL_SIZE (16 * 1024) +typedef void (*ngx_pool_cleanup_pt)(void *data); + +typedef struct ngx_pool_cleanup_s ngx_pool_cleanup_t; + +struct ngx_pool_cleanup_s { + ngx_pool_cleanup_pt handler; + void *data; + ngx_pool_cleanup_t *next; +}; + + typedef struct ngx_pool_large_s ngx_pool_large_t; struct ngx_pool_large_s { - ngx_pool_large_t *next; - void *alloc; + ngx_pool_large_t *next; + void *alloc; }; struct ngx_pool_s { - u_char *last; - u_char *end; - ngx_chain_t *chain; - ngx_pool_t *next; - ngx_pool_large_t *large; - ngx_log_t *log; + u_char *last; + u_char *end; + ngx_chain_t *chain; + ngx_pool_t *next; + ngx_pool_large_t *large; + ngx_pool_cleanup_t *cleanup; + ngx_log_t *log; }; +typedef struct { + ngx_fd_t fd; + u_char *name; + ngx_log_t *log; +} ngx_pool_cleanup_file_t; + + + void *ngx_alloc(size_t size, ngx_log_t *log); void *ngx_calloc(size_t size, ngx_log_t *log); @@ -51,4 +71,9 @@ void *ngx_pcalloc(ngx_pool_t *pool, size_t size); ngx_int_t ngx_pfree(ngx_pool_t *pool, void *p); +ngx_pool_cleanup_t *ngx_pool_cleanup_add(ngx_pool_t *p, + ngx_pool_cleanup_pt handler, void *data); +void ngx_pool_cleanup_file(void *data); + + #endif /* _NGX_PALLOC_H_INCLUDED_ */ diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c index e4fa69d7f..30938a174 100644 --- a/src/core/ngx_times.c +++ b/src/core/ngx_times.c @@ -12,8 +12,9 @@ ngx_epoch_msec_t ngx_elapsed_msec; ngx_epoch_msec_t ngx_old_elapsed_msec; ngx_epoch_msec_t ngx_start_msec; +ngx_int_t ngx_gmtoff; + static ngx_tm_t ngx_cached_gmtime; -static ngx_int_t ngx_gmtoff; /* diff --git a/src/core/ngx_times.h b/src/core/ngx_times.h index f9c4d3e3d..2959cc4b6 100644 --- a/src/core/ngx_times.h +++ b/src/core/ngx_times.h @@ -53,6 +53,7 @@ extern ngx_epoch_msec_t ngx_elapsed_msec; */ extern ngx_epoch_msec_t ngx_old_elapsed_msec; +extern ngx_int_t ngx_gmtoff; #endif /* _NGX_TIMES_H_INCLUDED_ */ diff --git a/src/core/ngx_unix_domain.c b/src/core/ngx_unix_domain.c index 3df83bb3e..a7fdd6357 100644 --- a/src/core/ngx_unix_domain.c +++ b/src/core/ngx_unix_domain.c @@ -14,8 +14,8 @@ #undef sun -ngx_peers_t *ngx_unix_upstream_parse(ngx_conf_t *cf, - ngx_unix_domain_upstream_t *u) +ngx_peers_t * +ngx_unix_upstream_parse(ngx_conf_t *cf, ngx_unix_domain_upstream_t *u) { size_t len; ngx_uint_t i; |