summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2005-03-04 14:04:26 +0000
committerJonathan Kolb <jon@b0g.us>2005-03-04 14:04:26 +0000
commitc5e300ff4b3366bcafaa41e44b8981c992669cec (patch)
tree4d3528124d88abae2db0594a921d7e834061cdee
parentf201d049a71e500be3ce9d85b93f034285344c38 (diff)
downloadnginx-c5e300ff4b3366bcafaa41e44b8981c992669cec.tar.gz
Changes with nginx 0.1.24 04 Mar 2005v0.1.24
*) Feature: the ngx_http_ssi_filter_module supports the QUERY_STRING and DOCUMENT_URI variables. *) Bugfix: the ngx_http_autoindex_module may some times return the 404 response for existent directory, if this directory was used in "alias" directive. *) Bugfix: the ngx_http_ssi_filter_module ran incorrectly for large responses. *) Bugfix: the lack of the "Referer" header line was always accounted as valid referrer.
-rw-r--r--CHANGES16
-rw-r--r--CHANGES.ru15
-rw-r--r--auto/cc/owc3
-rw-r--r--auto/sources2
-rw-r--r--src/core/nginx.c22
-rw-r--r--src/core/nginx.h2
-rw-r--r--src/core/ngx_buf.c74
-rw-r--r--src/core/ngx_buf.h32
-rw-r--r--src/core/ngx_conf_file.c2
-rw-r--r--src/core/ngx_config.h11
-rw-r--r--src/core/ngx_file.c2
-rw-r--r--src/core/ngx_file.h4
-rw-r--r--src/core/ngx_garbage_collector.c2
-rw-r--r--src/core/ngx_garbage_collector.h8
-rw-r--r--src/core/ngx_log.c2
-rw-r--r--src/core/ngx_log.h15
-rw-r--r--src/core/ngx_output_chain.c25
-rw-r--r--src/core/ngx_radix_tree.c2
-rw-r--r--src/core/ngx_regex.c2
-rw-r--r--src/core/ngx_regex.h2
-rw-r--r--src/core/ngx_times.c2
-rw-r--r--src/core/ngx_times.h2
-rw-r--r--src/event/modules/ngx_aio_module.c30
-rw-r--r--src/event/modules/ngx_devpoll_module.c64
-rw-r--r--src/event/modules/ngx_epoll_module.c53
-rw-r--r--src/event/modules/ngx_kqueue_module.c62
-rw-r--r--src/event/modules/ngx_poll_module.c18
-rw-r--r--src/event/modules/ngx_rtsig_module.c93
-rw-r--r--src/event/ngx_event.c2
-rw-r--r--src/http/modules/ngx_http_access_handler.c2
-rw-r--r--src/http/modules/ngx_http_autoindex_handler.c37
-rw-r--r--src/http/modules/ngx_http_charset_filter.c4
-rw-r--r--src/http/modules/ngx_http_fastcgi_handler.c4
-rw-r--r--src/http/modules/ngx_http_headers_filter.c2
-rw-r--r--src/http/modules/ngx_http_index_handler.c2
-rw-r--r--src/http/modules/ngx_http_range_filter.c6
-rw-r--r--src/http/modules/ngx_http_rewrite_handler.c26
-rw-r--r--src/http/modules/ngx_http_ssi_filter.c278
-rw-r--r--src/http/modules/ngx_http_static_handler.c2
-rw-r--r--src/http/modules/ngx_http_userid_filter.c113
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_upstream.c4
-rw-r--r--src/http/ngx_http.c58
-rw-r--r--src/http/ngx_http.h16
-rw-r--r--src/http/ngx_http_config.h7
-rw-r--r--src/http/ngx_http_core_module.c70
-rw-r--r--src/http/ngx_http_core_module.h29
-rw-r--r--src/http/ngx_http_header_filter.c72
-rw-r--r--src/http/ngx_http_log_handler.c2
-rw-r--r--src/http/ngx_http_request.c5
-rw-r--r--src/http/ngx_http_special_response.c55
-rw-r--r--src/http/ngx_http_variables.c338
-rw-r--r--src/http/ngx_http_variables.h61
-rw-r--r--src/http/ngx_http_write_filter.c17
-rw-r--r--src/os/unix/ngx_daemon.c2
-rw-r--r--src/os/unix/ngx_posix_init.c4
55 files changed, 1176 insertions, 609 deletions
diff --git a/CHANGES b/CHANGES
index e203c36bd..13e67e5a8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,20 @@
+Changes with nginx 0.1.24 04 Mar 2005
+
+ *) Feature: the ngx_http_ssi_filter_module supports the QUERY_STRING
+ and DOCUMENT_URI variables.
+
+ *) Bugfix: the ngx_http_autoindex_module may some times return the 404
+ response for existent directory, if this directory was used in
+ "alias" directive.
+
+ *) Bugfix: the ngx_http_ssi_filter_module ran incorrectly for large
+ responses.
+
+ *) Bugfix: the lack of the "Referer" header line was always accounted
+ as valid referrer.
+
+
Changes with nginx 0.1.23 01 Mar 2005
*) Feature: the ngx_http_ssi_filter_module and the ssi,
diff --git a/CHANGES.ru b/CHANGES.ru
index 43f8c9014..2bdac206e 100644
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,4 +1,19 @@
+Изменения в nginx 0.1.24 04.03.2005
+
+ *) Добавление: модуль ngx_http_ssi_filter_module поддерживает
+ переменные QUERY_STRING и DOCUMENT_URI.
+
+ *) Исправление: модуль ngx_http_autoindex_module мог выдавать ответ 404
+ на существующий каталог, если этот каталог был указан как alias.
+
+ *) Исправление: модуль ngx_http_ssi_filter_module неправильно работал
+ при больших ответах.
+
+ *) Исправление: отсутствие строки заголовка "Referer" всегда считалось
+ правильным referrer'ом.
+
+
Изменения в nginx 0.1.23 01.03.2005
*) Добавление: модуль ngx_http_ssi_filter_module и директивы ssi,
diff --git a/auto/cc/owc b/auto/cc/owc
index 06e5cc0e0..c2ab8f7ba 100644
--- a/auto/cc/owc
+++ b/auto/cc/owc
@@ -40,8 +40,9 @@ CFLAGS="$CFLAGS $CPU_OPT"
# warnings
-#CFLAGS="$CFLAGS -w3"
+# maximum level
CFLAGS="$CFLAGS -wx"
+#CFLAGS="$CFLAGS -w3"
# stop on warning
CFLAGS="$CFLAGS -we"
diff --git a/auto/sources b/auto/sources
index ac177f1df..57915de70 100644
--- a/auto/sources
+++ b/auto/sources
@@ -238,6 +238,7 @@ HTTP_DEPS="src/http/ngx_http.h \
src/http/ngx_http_config.h \
src/http/ngx_http_core_module.h \
src/http/ngx_http_cache.h \
+ src/http/ngx_http_variables.h \
src/http/ngx_http_upstream.h \
src/http/ngx_http_busy_lock.h \
src/http/ngx_http_log_handler.h"
@@ -252,6 +253,7 @@ HTTP_SRCS="src/http/ngx_http.c \
src/http/ngx_http_copy_filter.c \
src/http/ngx_http_log_handler.c \
src/http/ngx_http_request_body.c \
+ src/http/ngx_http_variables.c \
src/http/ngx_http_upstream.c \
src/http/ngx_http_parse_time.c \
src/http/modules/ngx_http_static_handler.c \
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 68da2ba1c..d6ee9f652 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -119,8 +119,8 @@ ngx_module_t ngx_core_module = {
ngx_uint_t ngx_max_module;
-
-int main(int argc, char *const *argv)
+int
+main(int argc, char *const *argv)
{
ngx_int_t i;
ngx_log_t *log;
@@ -252,7 +252,8 @@ int main(int argc, char *const *argv)
}
-static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_add_inherited_sockets(ngx_cycle_t *cycle)
{
u_char *p, *v, *inherited;
ngx_socket_t s;
@@ -407,7 +408,8 @@ static ngx_int_t ngx_getopt(ngx_cycle_t *cycle, int argc, char *const *argv)
}
-static ngx_int_t ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv)
+static ngx_int_t
+ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv)
{
size_t len;
ngx_int_t i;
@@ -444,7 +446,8 @@ static ngx_int_t ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv)
}
-static void *ngx_core_module_create_conf(ngx_cycle_t *cycle)
+static void *
+ngx_core_module_create_conf(ngx_cycle_t *cycle)
{
ngx_core_conf_t *ccf;
@@ -475,7 +478,8 @@ static void *ngx_core_module_create_conf(ngx_cycle_t *cycle)
}
-static char *ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
+static char *
+ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
{
ngx_core_conf_t *ccf = conf;
@@ -543,7 +547,8 @@ static char *ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
}
-static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+static char *
+ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
#if (NGX_WIN32)
@@ -603,7 +608,8 @@ static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
-static char *ngx_set_priority(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+static char *
+ngx_set_priority(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_core_conf_t *ccf = conf;
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 8fbc7482c..5f76b9b01 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.23"
+#define NGINX_VER "nginx/0.1.24"
#define NGINX_VAR "NGINX"
#define NGX_NEWPID_EXT ".newbin"
diff --git a/src/core/ngx_buf.c b/src/core/ngx_buf.c
index dedf4444e..97c94a363 100644
--- a/src/core/ngx_buf.c
+++ b/src/core/ngx_buf.c
@@ -8,7 +8,8 @@
#include <ngx_core.h>
-ngx_buf_t *ngx_create_temp_buf(ngx_pool_t *pool, size_t size)
+ngx_buf_t *
+ngx_create_temp_buf(ngx_pool_t *pool, size_t size)
{
ngx_buf_t *b;
@@ -20,28 +21,28 @@ ngx_buf_t *ngx_create_temp_buf(ngx_pool_t *pool, size_t size)
return NULL;
}
+ /*
+ * set by ngx_calloc_buf():
+ *
+ * b->file_pos = 0;
+ * b->file_last = 0;
+ * b->file = NULL;
+ * b->shadow = NULL;
+ * b->tag = 0;
+ *
+ */
+
b->pos = b->start;
b->last = b->start;
b->end = b->last + size;
b->temporary = 1;
- /*
-
- b->file_pos = 0;
- b->file_last = 0;
-
- b->file = NULL;
- b->shadow = NULL;
-
- b->tag = 0;
-
- */
-
return b;
}
-ngx_chain_t *ngx_create_chain_of_bufs(ngx_pool_t *pool, ngx_bufs_t *bufs)
+ngx_chain_t *
+ngx_create_chain_of_bufs(ngx_pool_t *pool, ngx_bufs_t *bufs)
{
u_char *p;
ngx_int_t i;
@@ -59,6 +60,17 @@ ngx_chain_t *ngx_create_chain_of_bufs(ngx_pool_t *pool, ngx_bufs_t *bufs)
return NULL;
}
+ /*
+ * set by ngx_calloc_buf():
+ *
+ * b->file_pos = 0;
+ * b->file_last = 0;
+ * b->file = NULL;
+ * b->shadow = NULL;
+ * b->tag = 0;
+ *
+ */
+
b->pos = p;
b->last = p;
b->temporary = 1;
@@ -67,15 +79,6 @@ ngx_chain_t *ngx_create_chain_of_bufs(ngx_pool_t *pool, ngx_bufs_t *bufs)
p += bufs->size;
b->end = p;
- /*
- b->file_pos = 0;
- b->file_last = 0;
-
- b->file = NULL;
- b->shadow = NULL;
- b->tag = 0;
- */
-
if (!(cl = ngx_alloc_chain_link(pool))) {
return NULL;
}
@@ -91,8 +94,8 @@ ngx_chain_t *ngx_create_chain_of_bufs(ngx_pool_t *pool, ngx_bufs_t *bufs)
}
-ngx_int_t ngx_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain,
- ngx_chain_t *in)
+ngx_int_t
+ngx_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain, ngx_chain_t *in)
{
ngx_chain_t *cl, **ll;
@@ -117,20 +120,19 @@ ngx_int_t ngx_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain,
}
-void ngx_chain_update_chains(ngx_chain_t **free, ngx_chain_t **busy,
- ngx_chain_t **out, ngx_buf_tag_t tag)
+void
+ngx_chain_update_chains(ngx_chain_t **free, ngx_chain_t **busy,
+ ngx_chain_t **out, ngx_buf_tag_t tag)
{
- ngx_chain_t *tl;
+ ngx_chain_t *cl;
if (*busy == NULL) {
*busy = *out;
} else {
- for (tl = *busy; tl->next; tl = tl->next) {
- /* void */;
- }
+ for (cl = *busy; cl->next; cl = cl->next) { /* void */ }
- tl->next = *out;
+ cl->next = *out;
}
*out = NULL;
@@ -154,9 +156,9 @@ void ngx_chain_update_chains(ngx_chain_t **free, ngx_chain_t **busy,
(*busy)->buf->pos = (*busy)->buf->start;
(*busy)->buf->last = (*busy)->buf->start;
- tl = *busy;
- *busy = (*busy)->next;
- tl->next = *free;
- *free = tl;
+ cl = *busy;
+ *busy = cl->next;
+ cl->next = *free;
+ *free = cl;
}
}
diff --git a/src/core/ngx_buf.h b/src/core/ngx_buf.h
index fbfd3946a..d672cf485 100644
--- a/src/core/ngx_buf.h
+++ b/src/core/ngx_buf.h
@@ -106,11 +106,11 @@ 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) && !ngx_buf_in_memory(b) && !b->in_file)
#define ngx_buf_size(b) \
- (ngx_buf_in_memory(b) ? (off_t) (b->last - b->pos): \
- (b->file_last - b->file_pos))
+ (ngx_buf_in_memory(b) ? (off_t) (b->last - b->pos): \
+ (b->file_last - b->file_pos))
ngx_buf_t *ngx_create_temp_buf(ngx_pool_t *pool, size_t size);
ngx_chain_t *ngx_create_chain_of_bufs(ngx_pool_t *pool, ngx_bufs_t *bufs);
@@ -124,29 +124,29 @@ ngx_chain_t *ngx_create_chain_of_bufs(ngx_pool_t *pool, ngx_bufs_t *bufs);
#define ngx_alloc_link_and_set_buf(chain, b, pool, error) \
- do { \
- ngx_test_null(chain, ngx_alloc_chain_link(pool), error); \
- chain->buf = b; \
- chain->next = NULL; \
- } while (0);
+ do { \
+ ngx_test_null(chain, ngx_alloc_chain_link(pool), error); \
+ chain->buf = b; \
+ chain->next = NULL; \
+ } while (0);
#define ngx_chain_add_link(chain, last, cl) \
- if (chain) { \
- *last = cl; \
- } else { \
- chain = cl; \
- } \
- last = &cl->next
+ if (chain) { \
+ *last = cl; \
+ } else { \
+ chain = cl; \
+ } \
+ last = &cl->next
ngx_int_t ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in);
ngx_int_t ngx_chain_writer(void *ctx, ngx_chain_t *in);
ngx_int_t ngx_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain,
- ngx_chain_t *in);
+ ngx_chain_t *in);
void ngx_chain_update_chains(ngx_chain_t **free, ngx_chain_t **busy,
- ngx_chain_t **out, ngx_buf_tag_t tag);
+ ngx_chain_t **out, ngx_buf_tag_t tag);
#endif /* _NGX_BUF_H_INCLUDED_ */
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index 436103a8c..437d7a283 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -30,7 +30,7 @@ ngx_module_t ngx_conf_module = {
ngx_conf_commands, /* module directives */
NGX_CONF_MODULE, /* module type */
NULL, /* init module */
- NULL /* init child */
+ NULL /* init process */
};
diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h
index dc791d406..bc02449dc 100644
--- a/src/core/ngx_config.h
+++ b/src/core/ngx_config.h
@@ -92,20 +92,13 @@ typedef long ngx_flag_t;
#if (NGX_SOLARIS)
-
-/* TODO: auto_conf */
-#define NGX_ALIGN (_MAX_ALIGNMENT - 1) /* platform word */
-#define NGX_ALIGN_CAST (unsigned long) /* size of the pointer */
-
+#define NGX_ALIGN (_MAX_ALIGNMENT - 1)
#else
-
/* TODO: auto_conf */
#define NGX_ALIGN (sizeof(unsigned long) - 1) /* platform word */
-#define NGX_ALIGN_CAST (unsigned long) /* size of the pointer */
-
#endif
-#define ngx_align(p) (u_char *) ((NGX_ALIGN_CAST p + NGX_ALIGN) & ~NGX_ALIGN)
+#define ngx_align(p) (u_char *) (((uintptr_t) p + NGX_ALIGN) & ~NGX_ALIGN)
/* TODO: auto_conf: ngx_inline inline __inline __inline__ */
diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c
index 514479cd2..561f080fd 100644
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -169,7 +169,7 @@ ngx_create_path(ngx_file_t *file, ngx_path_t *path)
void
-ngx_init_temp_number()
+ngx_init_temp_number(void)
{
ngx_temp_number = 0;
ngx_random = 123456;
diff --git a/src/core/ngx_file.h b/src/core/ngx_file.h
index f7832d775..c9063c5b4 100644
--- a/src/core/ngx_file.h
+++ b/src/core/ngx_file.h
@@ -26,7 +26,7 @@ struct ngx_file_s {
ngx_log_t *log;
- ngx_uint_t valid_info:1; /* unsigned valid_info:1; */
+ ngx_uint_t valid_info; /* unsigned valid_info:1; */
};
#define NGX_MAX_PATH_LEVEL 3
@@ -61,7 +61,7 @@ ngx_int_t ngx_create_path(ngx_file_t *file, ngx_path_t *path);
ngx_int_t ngx_add_path(ngx_conf_t *cf, ngx_path_t **slot);
ngx_int_t ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user);
-void ngx_init_temp_number();
+void ngx_init_temp_number(void);
ngx_atomic_uint_t ngx_next_temp_number(ngx_uint_t collision);
char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
diff --git a/src/core/ngx_garbage_collector.c b/src/core/ngx_garbage_collector.c
index fb6ad772d..ba7d7336f 100644
--- a/src/core/ngx_garbage_collector.c
+++ b/src/core/ngx_garbage_collector.c
@@ -10,7 +10,7 @@
-ngx_int_t ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level)
+ngx_int_t ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, ngx_int_t level)
{
int rc;
u_char *last;
diff --git a/src/core/ngx_garbage_collector.h b/src/core/ngx_garbage_collector.h
index cec3a87de..4b0a7344f 100644
--- a/src/core/ngx_garbage_collector.h
+++ b/src/core/ngx_garbage_collector.h
@@ -10,8 +10,8 @@
typedef struct ngx_gc_s ngx_gc_t;
-typedef int (*ngx_gc_handler_pt) (ngx_gc_t *ctx, ngx_str_t *name,
- ngx_dir_t *dir);
+typedef ngx_int_t (*ngx_gc_handler_pt) (ngx_gc_t *ctx, ngx_str_t *name,
+ ngx_dir_t *dir);
struct ngx_gc_s {
@@ -23,9 +23,9 @@ struct ngx_gc_s {
};
-ngx_int_t ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, int level);
+ngx_int_t ngx_collect_garbage(ngx_gc_t *ctx, ngx_str_t *dname, ngx_int_t level);
ngx_int_t ngx_garbage_collector_temp_handler(ngx_gc_t *ctx, ngx_str_t *name,
- ngx_dir_t *dir);
+ ngx_dir_t *dir);
#endif /* _NGX_GARBAGE_COLLECTOR_H_INCLUDED_ */
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index 58894e915..5d937f226 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -205,7 +205,7 @@ void ngx_log_debug_core(ngx_log_t *log, ngx_err_t err, const char *fmt, ...)
#endif
-ngx_log_t *ngx_log_init()
+ngx_log_t *ngx_log_init(void)
{
ngx_log.file = &ngx_stderr;
ngx_log.log_level = NGX_LOG_NOTICE;
diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h
index 48449a7fe..aae92e718 100644
--- a/src/core/ngx_log.h
+++ b/src/core/ngx_log.h
@@ -72,10 +72,10 @@ struct ngx_log_s {
#define NGX_HAVE_VARIADIC_MACROS 1
#define ngx_log_error(level, log, args...) \
- if (log->log_level >= level) ngx_log_error_core(level, log, args)
+ if (log->log_level >= level) ngx_log_error_core(level, log, args)
void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
- const char *fmt, ...);
+ const char *fmt, ...);
#define ngx_log_debug(level, log, args...) \
if (log->log_level & level) \
@@ -88,10 +88,10 @@ void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
#define NGX_HAVE_VARIADIC_MACROS 1
#define ngx_log_error(level, log, ...) \
- if (log->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__)
+ if (log->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__)
void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
- const char *fmt, ...);
+ const char *fmt, ...);
#define ngx_log_debug(level, log, ...) \
if (log->log_level & level) \
@@ -104,9 +104,9 @@ void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
#define NGX_HAVE_VARIADIC_MACROS 0
void ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
- const char *fmt, ...);
+ const char *fmt, ...);
void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
- const char *fmt, va_list args);
+ const char *fmt, va_list args);
void ngx_log_debug_core(ngx_log_t *log, ngx_err_t err, const char *fmt, ...);
@@ -195,12 +195,11 @@ void ngx_log_debug_core(ngx_log_t *log, ngx_err_t err, const char *fmt, ...);
#define ngx_log_alloc_log(pool, log) ngx_palloc(pool, log, sizeof(ngx_log_t))
#define ngx_log_copy_log(new, old) ngx_memcpy(new, old, sizeof(ngx_log_t))
-ngx_log_t *ngx_log_init();
+ngx_log_t *ngx_log_init(void);
ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_array_t *args);
char *ngx_set_error_log_levels(ngx_conf_t *cf, ngx_log_t *log);
-
extern ngx_module_t ngx_errlog_module;
diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
index 557dd22c9..5f6970f80 100644
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -20,12 +20,13 @@
static ngx_inline ngx_int_t
ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf);
static ngx_int_t ngx_output_chain_add_copy(ngx_pool_t *pool,
- ngx_chain_t **chain, ngx_chain_t *in);
+ ngx_chain_t **chain, ngx_chain_t *in);
static ngx_int_t ngx_output_chain_copy_buf(ngx_buf_t *dst, ngx_buf_t *src,
- ngx_uint_t sendfile);
+ ngx_uint_t sendfile);
-ngx_int_t ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
+ngx_int_t
+ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
{
int rc, last;
off_t bsize;
@@ -62,9 +63,9 @@ ngx_int_t ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
}
}
- last = NGX_NONE;
out = NULL;
last_out = &out;
+ last = NGX_NONE;
for ( ;; ) {
@@ -212,7 +213,7 @@ ngx_int_t ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
static ngx_inline ngx_int_t
- ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf)
+ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf)
{
ngx_uint_t sendfile;
@@ -251,8 +252,9 @@ static ngx_inline ngx_int_t
}
-static ngx_int_t ngx_output_chain_add_copy(ngx_pool_t *pool,
- ngx_chain_t **chain, ngx_chain_t *in)
+static ngx_int_t
+ngx_output_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain,
+ ngx_chain_t *in)
{
ngx_chain_t *cl, **ll;
#if (NGX_SENDFILE_LIMIT)
@@ -316,8 +318,8 @@ static ngx_int_t ngx_output_chain_add_copy(ngx_pool_t *pool,
}
-static ngx_int_t ngx_output_chain_copy_buf(ngx_buf_t *dst, ngx_buf_t *src,
- ngx_uint_t sendfile)
+static ngx_int_t
+ngx_output_chain_copy_buf(ngx_buf_t *dst, ngx_buf_t *src, ngx_uint_t sendfile)
{
off_t size;
ssize_t n;
@@ -408,14 +410,14 @@ static ngx_int_t ngx_output_chain_copy_buf(ngx_buf_t *dst, ngx_buf_t *src,
}
-ngx_int_t ngx_chain_writer(void *data, ngx_chain_t *in)
+ngx_int_t
+ngx_chain_writer(void *data, ngx_chain_t *in)
{
ngx_chain_writer_ctx_t *ctx = data;
off_t size;
ngx_chain_t *cl;
-
for (size = 0; in; in = in->next) {
#if 1
@@ -444,7 +446,6 @@ ngx_int_t ngx_chain_writer(void *data, ngx_chain_t *in)
for (cl = ctx->out; cl; cl = cl->next) {
#if 1
-
if (ngx_buf_size(cl->buf) == 0 && !ngx_buf_special(cl->buf)) {
ngx_debug_point();
}
diff --git a/src/core/ngx_radix_tree.c b/src/core/ngx_radix_tree.c
index 202421906..f8deb21f0 100644
--- a/src/core/ngx_radix_tree.c
+++ b/src/core/ngx_radix_tree.c
@@ -46,7 +46,7 @@ ngx_radix_tree_create(ngx_pool_t *pool, ngx_int_t preallocate)
* 8 - 8K, 9 - 16K, etc. On the 64-bit platforms the 6 preallocated bits
* takes continuous 4K, 7 - 8K, 8 - 16K, etc. There is no sense to
* to preallocate more than one page, because further preallocation
- * distribute the only bit per page. Instead, the random insertion
+ * distributes the only bit per page. Instead, the random insertion
* may distribute several bits per page.
*
* Thus, by default we preallocate maximum
diff --git a/src/core/ngx_regex.c b/src/core/ngx_regex.c
index 5a0f79314..bb719a52f 100644
--- a/src/core/ngx_regex.c
+++ b/src/core/ngx_regex.c
@@ -15,7 +15,7 @@ static void ngx_regex_free(void *p);
static ngx_pool_t *ngx_pcre_pool;
-void ngx_regex_init()
+void ngx_regex_init(void)
{
pcre_malloc = ngx_regex_malloc;
pcre_free = ngx_regex_free;
diff --git a/src/core/ngx_regex.h b/src/core/ngx_regex.h
index fb9856780..ff07fc7fb 100644
--- a/src/core/ngx_regex.h
+++ b/src/core/ngx_regex.h
@@ -20,7 +20,7 @@
typedef pcre ngx_regex_t;
-void ngx_regex_init();
+void ngx_regex_init(void);
ngx_regex_t *ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options,
ngx_pool_t *pool, ngx_str_t *err);
ngx_uint_t ngx_regex_capture_count(ngx_regex_t *re);
diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c
index 93542326f..42932892e 100644
--- a/src/core/ngx_times.c
+++ b/src/core/ngx_times.c
@@ -71,7 +71,7 @@ static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
-void ngx_time_init()
+void ngx_time_init(void)
{
struct timeval tv;
diff --git a/src/core/ngx_times.h b/src/core/ngx_times.h
index 17ffc43da..f9c4d3e3d 100644
--- a/src/core/ngx_times.h
+++ b/src/core/ngx_times.h
@@ -12,7 +12,7 @@
#include <ngx_core.h>
-void ngx_time_init();
+void ngx_time_init(void);
void ngx_time_update(time_t s);
u_char *ngx_http_time(u_char *buf, time_t t);
u_char *ngx_http_cookie_time(u_char *buf, time_t t);
diff --git a/src/event/modules/ngx_aio_module.c b/src/event/modules/ngx_aio_module.c
index bdd31cf9c..37a3a4499 100644
--- a/src/event/modules/ngx_aio_module.c
+++ b/src/event/modules/ngx_aio_module.c
@@ -14,12 +14,12 @@
#endif
-static int ngx_aio_init(ngx_cycle_t *cycle);
+static ngx_int_t ngx_aio_init(ngx_cycle_t *cycle);
static void ngx_aio_done(ngx_cycle_t *cycle);
-static int ngx_aio_add_event(ngx_event_t *ev, int event, u_int flags);
-static int ngx_aio_del_event(ngx_event_t *ev, int event, u_int flags);
-static int ngx_aio_del_connection(ngx_connection_t *c, u_int flags);
-static int ngx_aio_process_events(ngx_cycle_t *cycle);
+static ngx_int_t ngx_aio_add_event(ngx_event_t *ev, int event, u_int flags);
+static ngx_int_t ngx_aio_del_event(ngx_event_t *ev, int event, u_int flags);
+static ngx_int_t ngx_aio_del_connection(ngx_connection_t *c, u_int flags);
+static ngx_int_t ngx_aio_process_events(ngx_cycle_t *cycle);
ngx_os_io_t ngx_os_aio = {
@@ -66,7 +66,8 @@ ngx_module_t ngx_aio_module = {
#if (NGX_HAVE_KQUEUE)
-static int ngx_aio_init(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_aio_init(ngx_cycle_t *cycle)
{
if (ngx_kqueue_module_ctx.actions.init(cycle) == NGX_ERROR) {
return NGX_ERROR;
@@ -82,27 +83,31 @@ static int ngx_aio_init(ngx_cycle_t *cycle)
}
-static void ngx_aio_done(ngx_cycle_t *cycle)
+static void
+ngx_aio_done(ngx_cycle_t *cycle)
{
ngx_kqueue_module_ctx.actions.done(cycle);
}
-/* The event adding and deleting are needed for the listening sockets */
+/* the event adding and deleting are needed for the listening sockets */
-static int ngx_aio_add_event(ngx_event_t *ev, int event, u_int flags)
+static ngx_int_t
+ngx_aio_add_event(ngx_event_t *ev, int event, u_int flags)
{
return ngx_kqueue_module_ctx.actions.add(ev, event, flags);
}
-static int ngx_aio_del_event(ngx_event_t *ev, int event, u_int flags)
+static ngx_int_t
+ngx_aio_del_event(ngx_event_t *ev, int event, u_int flags)
{
return ngx_kqueue_module_ctx.actions.del(ev, event, flags);
}
-static int ngx_aio_del_connection(ngx_connection_t *c, u_int flags)
+static ngx_int_t
+ngx_aio_del_connection(ngx_connection_t *c, u_int flags)
{
int rc;
@@ -147,7 +152,8 @@ static int ngx_aio_del_connection(ngx_connection_t *c, u_int flags)
}
-static int ngx_aio_process_events(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_aio_process_events(ngx_cycle_t *cycle)
{
return ngx_kqueue_module_ctx.actions.process_events(cycle);
}
diff --git a/src/event/modules/ngx_devpoll_module.c b/src/event/modules/ngx_devpoll_module.c
index a9c60c46e..2d94ba477 100644
--- a/src/event/modules/ngx_devpoll_module.c
+++ b/src/event/modules/ngx_devpoll_module.c
@@ -31,12 +31,12 @@ typedef struct {
} ngx_devpoll_conf_t;
-static int ngx_devpoll_init(ngx_cycle_t *cycle);
+static ngx_int_t ngx_devpoll_init(ngx_cycle_t *cycle);
static void ngx_devpoll_done(ngx_cycle_t *cycle);
-static int ngx_devpoll_add_event(ngx_event_t *ev, int event, u_int flags);
-static int ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags);
-static int ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags);
-static int ngx_devpoll_process_events(ngx_cycle_t *cycle);
+static ngx_int_t ngx_devpoll_add_event(ngx_event_t *ev, int event, u_int flags);
+static ngx_int_t ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags);
+static ngx_int_t ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags);
+static ngx_int_t ngx_devpoll_process_events(ngx_cycle_t *cycle);
static void *ngx_devpoll_create_conf(ngx_cycle_t *cycle);
static char *ngx_devpoll_init_conf(ngx_cycle_t *cycle, void *conf);
@@ -52,21 +52,21 @@ static ngx_str_t devpoll_name = ngx_string("/dev/poll");
static ngx_command_t ngx_devpoll_commands[] = {
- {ngx_string("devpoll_changes"),
- NGX_EVENT_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_num_slot,
- 0,
- offsetof(ngx_devpoll_conf_t, changes),
- NULL},
-
- {ngx_string("devpoll_events"),
- NGX_EVENT_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_num_slot,
- 0,
- offsetof(ngx_devpoll_conf_t, events),
- NULL},
-
- ngx_null_command
+ { ngx_string("devpoll_changes"),
+ NGX_EVENT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ 0,
+ offsetof(ngx_devpoll_conf_t, changes),
+ NULL },
+
+ { ngx_string("devpoll_events"),
+ NGX_EVENT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ 0,
+ offsetof(ngx_devpoll_conf_t, events),
+ NULL },
+
+ ngx_null_command
};
@@ -100,7 +100,8 @@ ngx_module_t ngx_devpoll_module = {
};
-static int ngx_devpoll_init(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_devpoll_init(ngx_cycle_t *cycle)
{
size_t n;
ngx_devpoll_conf_t *dpcf;
@@ -173,7 +174,8 @@ static int ngx_devpoll_init(ngx_cycle_t *cycle)
}
-static void ngx_devpoll_done(ngx_cycle_t *cycle)
+static void
+ngx_devpoll_done(ngx_cycle_t *cycle)
{
if (close(dp) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
@@ -195,7 +197,8 @@ static void ngx_devpoll_done(ngx_cycle_t *cycle)
}
-static int ngx_devpoll_add_event(ngx_event_t *ev, int event, u_int flags)
+static ngx_int_t
+ngx_devpoll_add_event(ngx_event_t *ev, int event, u_int flags)
{
#if (NGX_DEBUG)
ngx_connection_t *c;
@@ -217,7 +220,8 @@ static int ngx_devpoll_add_event(ngx_event_t *ev, int event, u_int flags)
}
-static int ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags)
+static ngx_int_t
+ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags)
{
ngx_event_t *e;
ngx_connection_t *c;
@@ -260,7 +264,8 @@ static int ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags)
}
-static int ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags)
+static ngx_int_t
+ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags)
{
size_t n;
ngx_connection_t *c;
@@ -308,7 +313,8 @@ static int ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags)
}
-int ngx_devpoll_process_events(ngx_cycle_t *cycle)
+ngx_int_t
+ngx_devpoll_process_events(ngx_cycle_t *cycle)
{
int events, revents;
ngx_int_t i;
@@ -569,7 +575,8 @@ int ngx_devpoll_process_events(ngx_cycle_t *cycle)
}
-static void *ngx_devpoll_create_conf(ngx_cycle_t *cycle)
+static void *
+ngx_devpoll_create_conf(ngx_cycle_t *cycle)
{
ngx_devpoll_conf_t *dpcf;
@@ -583,7 +590,8 @@ static void *ngx_devpoll_create_conf(ngx_cycle_t *cycle)
}
-static char *ngx_devpoll_init_conf(ngx_cycle_t *cycle, void *conf)
+static char *
+ngx_devpoll_init_conf(ngx_cycle_t *cycle, void *conf)
{
ngx_devpoll_conf_t *dpcf = conf;
diff --git a/src/event/modules/ngx_epoll_module.c b/src/event/modules/ngx_epoll_module.c
index af2781851..f2c973f24 100644
--- a/src/event/modules/ngx_epoll_module.c
+++ b/src/event/modules/ngx_epoll_module.c
@@ -70,13 +70,13 @@ typedef struct {
} ngx_epoll_conf_t;
-static int ngx_epoll_init(ngx_cycle_t *cycle);
+static ngx_int_t ngx_epoll_init(ngx_cycle_t *cycle);
static void ngx_epoll_done(ngx_cycle_t *cycle);
-static int ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags);
-static int ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags);
-static int ngx_epoll_add_connection(ngx_connection_t *c);
-static int ngx_epoll_del_connection(ngx_connection_t *c, u_int flags);
-static int ngx_epoll_process_events(ngx_cycle_t *cycle);
+static ngx_int_t ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags);
+static ngx_int_t ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags);
+static ngx_int_t ngx_epoll_add_connection(ngx_connection_t *c);
+static ngx_int_t ngx_epoll_del_connection(ngx_connection_t *c, u_int flags);
+static ngx_int_t ngx_epoll_process_events(ngx_cycle_t *cycle);
static void *ngx_epoll_create_conf(ngx_cycle_t *cycle);
static char *ngx_epoll_init_conf(ngx_cycle_t *cycle, void *conf);
@@ -90,14 +90,14 @@ static ngx_str_t epoll_name = ngx_string("epoll");
static ngx_command_t ngx_epoll_commands[] = {
- {ngx_string("epoll_events"),
- NGX_EVENT_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_num_slot,
- 0,
- offsetof(ngx_epoll_conf_t, events),
- NULL},
+ { ngx_string("epoll_events"),
+ NGX_EVENT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ 0,
+ offsetof(ngx_epoll_conf_t, events),
+ NULL },
- ngx_null_command
+ ngx_null_command
};
@@ -130,7 +130,8 @@ ngx_module_t ngx_epoll_module = {
};
-static int ngx_epoll_init(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_epoll_init(ngx_cycle_t *cycle)
{
size_t n;
ngx_event_conf_t *ecf;
@@ -180,7 +181,8 @@ static int ngx_epoll_init(ngx_cycle_t *cycle)
}
-static void ngx_epoll_done(ngx_cycle_t *cycle)
+static void
+ngx_epoll_done(ngx_cycle_t *cycle)
{
if (close(ep) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
@@ -196,7 +198,8 @@ static void ngx_epoll_done(ngx_cycle_t *cycle)
}
-static int ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
+static ngx_int_t
+ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
{
int op;
uint32_t events, prev;
@@ -253,7 +256,8 @@ static int ngx_epoll_add_event(ngx_event_t *ev, int event, u_int flags)
}
-static int ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags)
+static ngx_int_t
+ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags)
{
int op;
uint32_t prev;
@@ -310,7 +314,8 @@ static int ngx_epoll_del_event(ngx_event_t *ev, int event, u_int flags)
}
-static int ngx_epoll_add_connection(ngx_connection_t *c)
+static ngx_int_t
+ngx_epoll_add_connection(ngx_connection_t *c)
{
struct epoll_event ee;
@@ -333,7 +338,8 @@ static int ngx_epoll_add_connection(ngx_connection_t *c)
}
-static int ngx_epoll_del_connection(ngx_connection_t *c, u_int flags)
+static ngx_int_t
+ngx_epoll_del_connection(ngx_connection_t *c, u_int flags)
{
int op;
struct epoll_event ee;
@@ -370,7 +376,8 @@ static int ngx_epoll_del_connection(ngx_connection_t *c, u_int flags)
}
-int ngx_epoll_process_events(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_epoll_process_events(ngx_cycle_t *cycle)
{
int events;
size_t n;
@@ -651,7 +658,8 @@ int ngx_epoll_process_events(ngx_cycle_t *cycle)
}
-static void *ngx_epoll_create_conf(ngx_cycle_t *cycle)
+static void *
+ngx_epoll_create_conf(ngx_cycle_t *cycle)
{
ngx_epoll_conf_t *epcf;
@@ -664,7 +672,8 @@ static void *ngx_epoll_create_conf(ngx_cycle_t *cycle)
}
-static char *ngx_epoll_init_conf(ngx_cycle_t *cycle, void *conf)
+static char *
+ngx_epoll_init_conf(ngx_cycle_t *cycle, void *conf)
{
ngx_epoll_conf_t *epcf = conf;
diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c
index 49770fd56..b4555d983 100644
--- a/src/event/modules/ngx_kqueue_module.c
+++ b/src/event/modules/ngx_kqueue_module.c
@@ -24,7 +24,7 @@ static ngx_int_t ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags);
static ngx_int_t ngx_kqueue_process_changes(ngx_cycle_t *cycle, ngx_uint_t try);
static ngx_int_t ngx_kqueue_process_events(ngx_cycle_t *cycle);
static ngx_inline void ngx_kqueue_dump_event(ngx_log_t *log,
- struct kevent *kev);
+ struct kevent *kev);
static void *ngx_kqueue_create_conf(ngx_cycle_t *cycle);
static char *ngx_kqueue_init_conf(ngx_cycle_t *cycle, void *conf);
@@ -55,21 +55,21 @@ static ngx_str_t kqueue_name = ngx_string("kqueue");
static ngx_command_t ngx_kqueue_commands[] = {
- {ngx_string("kqueue_changes"),
- NGX_EVENT_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_num_slot,
- 0,
- offsetof(ngx_kqueue_conf_t, changes),
- NULL},
-
- {ngx_string("kqueue_events"),
- NGX_EVENT_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_num_slot,
- 0,
- offsetof(ngx_kqueue_conf_t, events),
- NULL},
-
- ngx_null_command
+ { ngx_string("kqueue_changes"),
+ NGX_EVENT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ 0,
+ offsetof(ngx_kqueue_conf_t, changes),
+ NULL },
+
+ { ngx_string("kqueue_events"),
+ NGX_EVENT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ 0,
+ offsetof(ngx_kqueue_conf_t, events),
+ NULL },
+
+ ngx_null_command
};
@@ -104,7 +104,8 @@ ngx_module_t ngx_kqueue_module = {
-static ngx_int_t ngx_kqueue_init(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_kqueue_init(ngx_cycle_t *cycle)
{
struct timespec ts;
ngx_kqueue_conf_t *kcf;
@@ -203,7 +204,8 @@ static ngx_int_t ngx_kqueue_init(ngx_cycle_t *cycle)
}
-static void ngx_kqueue_done(ngx_cycle_t *cycle)
+static void
+ngx_kqueue_done(ngx_cycle_t *cycle)
{
if (close(ngx_kqueue) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
@@ -231,7 +233,8 @@ static void ngx_kqueue_done(ngx_cycle_t *cycle)
}
-static ngx_int_t ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags)
+static ngx_int_t
+ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags)
{
ngx_int_t rc;
ngx_event_t *e;
@@ -295,7 +298,8 @@ static ngx_int_t ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags)
}
-static ngx_int_t ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
+static ngx_int_t
+ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
{
ngx_int_t rc;
ngx_event_t *e;
@@ -358,7 +362,8 @@ static ngx_int_t ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
}
-static ngx_int_t ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags)
+static ngx_int_t
+ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags)
{
struct kevent *kev;
struct timespec ts;
@@ -425,7 +430,8 @@ static ngx_int_t ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags)
}
-static ngx_int_t ngx_kqueue_process_events(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_kqueue_process_events(ngx_cycle_t *cycle)
{
int events, n;
ngx_int_t i, instance;
@@ -715,7 +721,8 @@ static ngx_int_t ngx_kqueue_process_events(ngx_cycle_t *cycle)
}
-static ngx_int_t ngx_kqueue_process_changes(ngx_cycle_t *cycle, ngx_uint_t try)
+static ngx_int_t
+ngx_kqueue_process_changes(ngx_cycle_t *cycle, ngx_uint_t try)
{
int n;
ngx_int_t rc;
@@ -772,7 +779,8 @@ static ngx_int_t ngx_kqueue_process_changes(ngx_cycle_t *cycle, ngx_uint_t try)
}
-static ngx_inline void ngx_kqueue_dump_event(ngx_log_t *log, struct kevent *kev)
+static ngx_inline void
+ngx_kqueue_dump_event(ngx_log_t *log, struct kevent *kev)
{
ngx_log_debug6(NGX_LOG_DEBUG_EVENT, log, 0,
(kev->ident > 0x8000000 && kev->ident != (unsigned) -1) ?
@@ -784,7 +792,8 @@ static ngx_inline void ngx_kqueue_dump_event(ngx_log_t *log, struct kevent *kev)
}
-static void *ngx_kqueue_create_conf(ngx_cycle_t *cycle)
+static void *
+ngx_kqueue_create_conf(ngx_cycle_t *cycle)
{
ngx_kqueue_conf_t *kcf;
@@ -798,7 +807,8 @@ static void *ngx_kqueue_create_conf(ngx_cycle_t *cycle)
}
-static char *ngx_kqueue_init_conf(ngx_cycle_t *cycle, void *conf)
+static char *
+ngx_kqueue_init_conf(ngx_cycle_t *cycle, void *conf)
{
ngx_kqueue_conf_t *kcf = conf;
diff --git a/src/event/modules/ngx_poll_module.c b/src/event/modules/ngx_poll_module.c
index 12726b58d..6ea3af4e4 100644
--- a/src/event/modules/ngx_poll_module.c
+++ b/src/event/modules/ngx_poll_module.c
@@ -60,7 +60,8 @@ ngx_module_t ngx_poll_module = {
-static ngx_int_t ngx_poll_init(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_poll_init(ngx_cycle_t *cycle)
{
struct pollfd *list;
@@ -106,7 +107,8 @@ static ngx_int_t ngx_poll_init(ngx_cycle_t *cycle)
}
-static void ngx_poll_done(ngx_cycle_t *cycle)
+static void
+ngx_poll_done(ngx_cycle_t *cycle)
{
ngx_free(event_list);
#if 0
@@ -120,7 +122,8 @@ static void ngx_poll_done(ngx_cycle_t *cycle)
}
-static ngx_int_t ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags)
+static ngx_int_t
+ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags)
{
ngx_event_t *e;
ngx_connection_t *c;
@@ -173,7 +176,8 @@ static ngx_int_t ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags)
}
-static ngx_int_t ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags)
+static ngx_int_t
+ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags)
{
ngx_uint_t i;
ngx_cycle_t **cycle;
@@ -260,7 +264,8 @@ static ngx_int_t ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags)
}
-static ngx_int_t ngx_poll_process_events(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_poll_process_events(ngx_cycle_t *cycle)
{
int ready, revents;
ngx_int_t i, nready;
@@ -590,7 +595,8 @@ static ngx_int_t ngx_poll_process_events(ngx_cycle_t *cycle)
}
-static char *ngx_poll_init_conf(ngx_cycle_t *cycle, void *conf)
+static char *
+ngx_poll_init_conf(ngx_cycle_t *cycle, void *conf)
{
ngx_event_conf_t *ecf;
diff --git a/src/event/modules/ngx_rtsig_module.c b/src/event/modules/ngx_rtsig_module.c
index f1df54991..07b8bd9d6 100644
--- a/src/event/modules/ngx_rtsig_module.c
+++ b/src/event/modules/ngx_rtsig_module.c
@@ -48,7 +48,7 @@ static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle);
static void *ngx_rtsig_create_conf(ngx_cycle_t *cycle);
static char *ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf);
static char *ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf,
- void *post, void *data);
+ void *post, void *data);
static sigset_t set;
@@ -65,35 +65,35 @@ static ngx_conf_num_bounds_t ngx_overflow_threshold_bounds = {
static ngx_command_t ngx_rtsig_commands[] = {
- {ngx_string("rtsig_signo"),
- NGX_EVENT_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_num_slot,
- 0,
- offsetof(ngx_rtsig_conf_t, signo),
- NULL},
-
- {ngx_string("rtsig_overflow_events"),
- NGX_EVENT_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_num_slot,
- 0,
- offsetof(ngx_rtsig_conf_t, overflow_events),
- NULL},
-
- {ngx_string("rtsig_overflow_test"),
- NGX_EVENT_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_num_slot,
- 0,
- offsetof(ngx_rtsig_conf_t, overflow_test),
- NULL},
-
- {ngx_string("rtsig_overflow_threshold"),
- NGX_EVENT_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_num_slot,
- 0,
- offsetof(ngx_rtsig_conf_t, overflow_threshold),
- &ngx_overflow_threshold_bounds},
-
- ngx_null_command
+ { ngx_string("rtsig_signo"),
+ NGX_EVENT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ 0,
+ offsetof(ngx_rtsig_conf_t, signo),
+ NULL },
+
+ { ngx_string("rtsig_overflow_events"),
+ NGX_EVENT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ 0,
+ offsetof(ngx_rtsig_conf_t, overflow_events),
+ NULL },
+
+ { ngx_string("rtsig_overflow_test"),
+ NGX_EVENT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ 0,
+ offsetof(ngx_rtsig_conf_t, overflow_test),
+ NULL },
+
+ { ngx_string("rtsig_overflow_threshold"),
+ NGX_EVENT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ 0,
+ offsetof(ngx_rtsig_conf_t, overflow_threshold),
+ &ngx_overflow_threshold_bounds },
+
+ ngx_null_command
};
@@ -121,13 +121,14 @@ ngx_module_t ngx_rtsig_module = {
NGX_MODULE,
&ngx_rtsig_module_ctx, /* module context */
ngx_rtsig_commands, /* module directives */
- NGX_EVENT_MODULE, /* module type */
- NULL, /* init module */
- NULL /* init process */
+ NGX_EVENT_MODULE, /* module type */
+ NULL, /* init module */
+ NULL /* init process */
};
-static ngx_int_t ngx_rtsig_init(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_rtsig_init(ngx_cycle_t *cycle)
{
ngx_rtsig_conf_t *rtscf;
@@ -164,7 +165,8 @@ static ngx_int_t ngx_rtsig_init(ngx_cycle_t *cycle)
}
-static void ngx_rtsig_done(ngx_cycle_t *cycle)
+static void
+ngx_rtsig_done(ngx_cycle_t *cycle)
{
ngx_free(overflow_list);
@@ -172,7 +174,8 @@ static void ngx_rtsig_done(ngx_cycle_t *cycle)
}
-static ngx_int_t ngx_rtsig_add_connection(ngx_connection_t *c)
+static ngx_int_t
+ngx_rtsig_add_connection(ngx_connection_t *c)
{
int signo;
ngx_rtsig_conf_t *rtscf;
@@ -232,7 +235,8 @@ static ngx_int_t ngx_rtsig_add_connection(ngx_connection_t *c)
}
-static ngx_int_t ngx_rtsig_del_connection(ngx_connection_t *c, u_int flags)
+static ngx_int_t
+ngx_rtsig_del_connection(ngx_connection_t *c, u_int flags)
{
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
"rtsig del connection: fd:%d", c->fd);
@@ -266,7 +270,8 @@ static ngx_int_t ngx_rtsig_del_connection(ngx_connection_t *c, u_int flags)
}
-ngx_int_t ngx_rtsig_process_events(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_rtsig_process_events(ngx_cycle_t *cycle)
{
int signo;
ngx_int_t instance, i;
@@ -562,7 +567,8 @@ ngx_int_t ngx_rtsig_process_events(ngx_cycle_t *cycle)
/* TODO: old cylces */
-static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_rtsig_process_overflow(ngx_cycle_t *cycle)
{
int name[2], rtsig_max, rtsig_nr, events, ready;
size_t len;
@@ -766,7 +772,8 @@ static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle)
}
-static void *ngx_rtsig_create_conf(ngx_cycle_t *cycle)
+static void *
+ngx_rtsig_create_conf(ngx_cycle_t *cycle)
{
ngx_rtsig_conf_t *rtscf;
@@ -782,7 +789,8 @@ static void *ngx_rtsig_create_conf(ngx_cycle_t *cycle)
}
-static char *ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf)
+static char *
+ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf)
{
ngx_rtsig_conf_t *rtscf = conf;
@@ -797,7 +805,8 @@ static char *ngx_rtsig_init_conf(ngx_cycle_t *cycle, void *conf)
}
-static char *ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf,
+static char *
+ngx_check_ngx_overflow_threshold_bounds(ngx_conf_t *cf,
void *post, void *data)
{
if (ngx_linux_rtsig_max) {
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index 38efca0b8..5a002c001 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -715,7 +715,7 @@ static void *ngx_event_create_conf(ngx_cycle_t *cycle)
ecf->name = (void *) NGX_CONF_UNSET;
#if (NGX_DEBUG)
- ngx_init_array(ecf->debug_connection, cycle->pool, 5, sizeof(in_addr_t),
+ ngx_init_array(ecf->debug_connection, cycle->pool, 4, sizeof(in_addr_t),
NGX_CONF_ERROR);
#endif
diff --git a/src/http/modules/ngx_http_access_handler.c b/src/http/modules/ngx_http_access_handler.c
index 832f9c2ed..285570f23 100644
--- a/src/http/modules/ngx_http_access_handler.c
+++ b/src/http/modules/ngx_http_access_handler.c
@@ -127,7 +127,7 @@ static char *ngx_http_access_rule(ngx_conf_t *cf, ngx_command_t *cmd,
ngx_http_access_rule_t *rule;
if (alcf->rules == NULL) {
- alcf->rules = ngx_create_array(cf->pool, 5,
+ alcf->rules = ngx_create_array(cf->pool, 4,
sizeof(ngx_http_access_rule_t));
if (alcf->rules == NULL) {
return NGX_CONF_ERROR;
diff --git a/src/http/modules/ngx_http_autoindex_handler.c b/src/http/modules/ngx_http_autoindex_handler.c
index f7878c9b9..8976ad546 100644
--- a/src/http/modules/ngx_http_autoindex_handler.c
+++ b/src/http/modules/ngx_http_autoindex_handler.c
@@ -40,12 +40,12 @@ typedef struct {
static int ngx_http_autoindex_cmp_entries(const void *one, const void *two);
-static ngx_int_t ngx_http_autoindex_error(ngx_http_request_t *r, ngx_dir_t *dir,
- u_char *name);
+static ngx_int_t ngx_http_autoindex_error(ngx_http_request_t *r,
+ ngx_dir_t *dir, u_char *name);
static ngx_int_t ngx_http_autoindex_init(ngx_cycle_t *cycle);
static void *ngx_http_autoindex_create_loc_conf(ngx_conf_t *cf);
static char *ngx_http_autoindex_merge_loc_conf(ngx_conf_t *cf,
- void *parent, void *child);
+ void *parent, void *child);
static ngx_command_t ngx_http_autoindex_commands[] = {
@@ -81,7 +81,7 @@ ngx_module_t ngx_http_autoindex_module = {
ngx_http_autoindex_commands, /* module directives */
NGX_HTTP_MODULE, /* module type */
ngx_http_autoindex_init, /* init module */
- NULL /* init child */
+ NULL /* init process */
};
@@ -103,7 +103,8 @@ static u_char tail[] =
;
-static ngx_int_t ngx_http_autoindex_handler(ngx_http_request_t *r)
+static ngx_int_t
+ngx_http_autoindex_handler(ngx_http_request_t *r)
{
u_char *last;
size_t len;
@@ -146,7 +147,7 @@ static ngx_int_t ngx_http_autoindex_handler(ngx_http_request_t *r)
if (clcf->alias) {
dname.data = ngx_palloc(pool, clcf->root.len + r->uri.len
- + NGX_DIR_MASK_LEN
+ + NGX_DIR_MASK_LEN + 1
- clcf->name.len);
if (dname.data == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
@@ -154,7 +155,7 @@ static ngx_int_t ngx_http_autoindex_handler(ngx_http_request_t *r)
last = ngx_cpymem(dname.data, clcf->root.data, clcf->root.len);
last = ngx_cpystrn(last, r->uri.data + clcf->name.len,
- r->uri.len - clcf->name.len);
+ r->uri.len - clcf->name.len + 1);
} else {
dname.data = ngx_palloc(pool, clcf->root.len + r->uri.len
@@ -165,7 +166,6 @@ static ngx_int_t ngx_http_autoindex_handler(ngx_http_request_t *r)
last = ngx_cpymem(dname.data, clcf->root.data, clcf->root.len);
last = ngx_cpystrn(last, r->uri.data, r->uri.len);
-
}
dname.len = last - dname.data;
@@ -445,7 +445,8 @@ static ngx_int_t ngx_http_autoindex_handler(ngx_http_request_t *r)
}
-static int ngx_http_autoindex_cmp_entries(const void *one, const void *two)
+static int
+ngx_http_autoindex_cmp_entries(const void *one, const void *two)
{
ngx_http_autoindex_entry_t *first = (ngx_http_autoindex_entry_t *) one;
ngx_http_autoindex_entry_t *second = (ngx_http_autoindex_entry_t *) two;
@@ -466,8 +467,8 @@ static int ngx_http_autoindex_cmp_entries(const void *one, const void *two)
#if 0
-static ngx_buf_t *ngx_http_autoindex_alloc(ngx_http_autoindex_ctx_t *ctx,
- size_t size)
+static ngx_buf_t *
+ngx_http_autoindex_alloc(ngx_http_autoindex_ctx_t *ctx, size_t size)
{
ngx_chain_t *cl;
@@ -500,8 +501,8 @@ static ngx_buf_t *ngx_http_autoindex_alloc(ngx_http_autoindex_ctx_t *ctx,
#endif
-static ngx_int_t ngx_http_autoindex_error(ngx_http_request_t *r, ngx_dir_t *dir,
- u_char *name)
+static ngx_int_t
+ngx_http_autoindex_error(ngx_http_request_t *r, ngx_dir_t *dir, u_char *name)
{
if (ngx_close_dir(dir) == NGX_ERROR) {
ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
@@ -512,7 +513,8 @@ static ngx_int_t ngx_http_autoindex_error(ngx_http_request_t *r, ngx_dir_t *dir,
}
-static ngx_int_t ngx_http_autoindex_init(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_http_autoindex_init(ngx_cycle_t *cycle)
{
ngx_http_handler_pt *h;
ngx_http_core_main_conf_t *cmcf;
@@ -530,7 +532,8 @@ static ngx_int_t ngx_http_autoindex_init(ngx_cycle_t *cycle)
}
-static void *ngx_http_autoindex_create_loc_conf(ngx_conf_t *cf)
+static void *
+ngx_http_autoindex_create_loc_conf(ngx_conf_t *cf)
{
ngx_http_autoindex_loc_conf_t *conf;
@@ -545,8 +548,8 @@ static void *ngx_http_autoindex_create_loc_conf(ngx_conf_t *cf)
}
-static char *ngx_http_autoindex_merge_loc_conf(ngx_conf_t *cf,
- void *parent, void *child)
+static char *
+ngx_http_autoindex_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
{
ngx_http_autoindex_loc_conf_t *prev = parent;
ngx_http_autoindex_loc_conf_t *conf = child;
diff --git a/src/http/modules/ngx_http_charset_filter.c b/src/http/modules/ngx_http_charset_filter.c
index 0aea91e2f..cbd0fca75 100644
--- a/src/http/modules/ngx_http_charset_filter.c
+++ b/src/http/modules/ngx_http_charset_filter.c
@@ -456,10 +456,10 @@ static void *ngx_http_charset_create_main_conf(ngx_conf_t *cf)
return NGX_CONF_ERROR;
}
- ngx_init_array(mcf->charsets, cf->pool, 5, sizeof(ngx_http_charset_t),
+ ngx_init_array(mcf->charsets, cf->pool, 2, sizeof(ngx_http_charset_t),
NGX_CONF_ERROR);
- ngx_init_array(mcf->tables, cf->pool, 10, sizeof(ngx_http_charset_tables_t),
+ ngx_init_array(mcf->tables, cf->pool, 4, sizeof(ngx_http_charset_tables_t),
NGX_CONF_ERROR);
return mcf;
diff --git a/src/http/modules/ngx_http_fastcgi_handler.c b/src/http/modules/ngx_http_fastcgi_handler.c
index d6130794a..5b384b86e 100644
--- a/src/http/modules/ngx_http_fastcgi_handler.c
+++ b/src/http/modules/ngx_http_fastcgi_handler.c
@@ -599,7 +599,7 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
for (i = 0; i < flcf->vars->nelts; i++) {
- if (!(value = ngx_http_get_variable(r, vindex[i]))) {
+ if (!(value = ngx_http_get_indexed_variable(r, vindex[i]))) {
continue;
}
@@ -998,7 +998,7 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
if (flcf->vars) {
for (i = 0; i < flcf->vars->nelts; i++) {
- if (!(value = ngx_http_get_variable(r, vindex[i]))) {
+ if (!(value = ngx_http_get_indexed_variable(r, vindex[i]))) {
continue;
}
diff --git a/src/http/modules/ngx_http_headers_filter.c b/src/http/modules/ngx_http_headers_filter.c
index ab334148e..39b35837b 100644
--- a/src/http/modules/ngx_http_headers_filter.c
+++ b/src/http/modules/ngx_http_headers_filter.c
@@ -59,7 +59,7 @@ ngx_module_t ngx_http_headers_filter_module = {
ngx_http_headers_filter_commands, /* module directives */
NGX_HTTP_MODULE, /* module type */
ngx_http_headers_filter_init, /* init module */
- NULL /* init child */
+ NULL /* init process */
};
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c
index 1c7d0dfad..4e3755766 100644
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -86,7 +86,7 @@ ngx_module_t ngx_http_index_module = {
ngx_http_index_commands, /* module directives */
NGX_HTTP_MODULE, /* module type */
ngx_http_index_init, /* init module */
- NULL /* init child */
+ NULL /* init process */
};
diff --git a/src/http/modules/ngx_http_range_filter.c b/src/http/modules/ngx_http_range_filter.c
index 0049af6cb..03f274560 100644
--- a/src/http/modules/ngx_http_range_filter.c
+++ b/src/http/modules/ngx_http_range_filter.c
@@ -73,7 +73,7 @@ ngx_module_t ngx_http_range_header_filter_module = {
NULL, /* module directives */
NGX_HTTP_MODULE, /* module type */
ngx_http_range_header_filter_init, /* init module */
- NULL /* init child */
+ NULL /* init process */
};
@@ -97,7 +97,7 @@ ngx_module_t ngx_http_range_body_filter_module = {
NULL, /* module directives */
NGX_HTTP_MODULE, /* module type */
ngx_http_range_body_filter_init, /* init module */
- NULL /* init child */
+ NULL /* init process */
};
@@ -144,7 +144,7 @@ ngx_http_range_header_filter(ngx_http_request_t *r)
return ngx_http_next_header_filter(r);
}
- if (ngx_array_init(&r->headers_out.ranges, r->pool, 5,
+ if (ngx_array_init(&r->headers_out.ranges, r->pool, 2,
sizeof(ngx_http_range_t)) == NGX_ERROR)
{
return NGX_ERROR;
diff --git a/src/http/modules/ngx_http_rewrite_handler.c b/src/http/modules/ngx_http_rewrite_handler.c
index d3c721fda..3080bd6f4 100644
--- a/src/http/modules/ngx_http_rewrite_handler.c
+++ b/src/http/modules/ngx_http_rewrite_handler.c
@@ -540,7 +540,7 @@ ngx_http_rewrite_var_code(ngx_http_rewrite_engine_t *e)
e->ip += sizeof(ngx_http_rewrite_var_code_t);
- if (!(value = ngx_http_get_variable(e->request, code->index))) {
+ if (!(value = ngx_http_get_indexed_variable(e->request, code->index))) {
*e->sp = (uintptr_t) 0;
return;
}
@@ -698,6 +698,10 @@ ngx_http_rewrite_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_value(conf->no_referer, prev->no_referer, 0);
}
+ if (conf->no_referer == NGX_CONF_UNSET) {
+ conf->no_referer = 0;
+ }
+
if (conf->codes == NULL) {
return NGX_CONF_OK;
}
@@ -1025,12 +1029,12 @@ ngx_http_rewrite_if(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
char *rv;
u_char *elts;
ngx_str_t *value;
+ ngx_int_t index;
ngx_uint_t i;
ngx_conf_t save;
ngx_http_rewrite_code_pt *code;
ngx_http_module_t *module;
ngx_http_conf_ctx_t *ctx, *pctx;
- ngx_http_variable_t *var;
ngx_http_core_loc_conf_t *clcf, *pclcf, **clcfp;
ngx_http_core_main_conf_t *cmcf;
ngx_http_rewrite_if_code_t *if_code;
@@ -1119,23 +1123,11 @@ ngx_http_rewrite_if(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
*code = ngx_http_rewrite_invalid_referer_code;
} else {
-
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
- var = cmcf->variables.elts;
- for (i = 0; i < cmcf->variables.nelts; i++) {
- if (var[i].name.len != value[1].len) {
- continue;
- }
-
- if (ngx_strncasecmp(var[i].name.data, value[1].data,
- var[i].name.len) == 0)
- {
- break;
- }
- }
+ index = ngx_http_get_variable_index(cmcf, &value[1]);
- if (i == cmcf->variables.nelts) {
+ if (index == -1) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"unknown variable name \"%V\"", &value[1]);
return NGX_CONF_ERROR;
@@ -1148,7 +1140,7 @@ ngx_http_rewrite_if(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
var_code->code = ngx_http_rewrite_var_code;
- var_code->index = var[i].index;
+ var_code->index = index;
}
if_code = ngx_array_push_n(lcf->codes, sizeof(ngx_http_rewrite_if_code_t));
diff --git a/src/http/modules/ngx_http_ssi_filter.c b/src/http/modules/ngx_http_ssi_filter.c
index f4b9737eb..ca877ac94 100644
--- a/src/http/modules/ngx_http_ssi_filter.c
+++ b/src/http/modules/ngx_http_ssi_filter.c
@@ -41,6 +41,8 @@ typedef struct {
ngx_chain_t *in;
ngx_chain_t *out;
ngx_chain_t **last_out;
+ ngx_chain_t *busy;
+ ngx_chain_t *free;
ngx_uint_t state;
ngx_uint_t saved_state;
@@ -158,7 +160,7 @@ ngx_module_t ngx_http_ssi_filter_module = {
ngx_http_ssi_filter_commands, /* module directives */
NGX_HTTP_MODULE, /* module type */
ngx_http_ssi_filter_init, /* init module */
- NULL /* init child */
+ NULL /* init process */
};
@@ -212,7 +214,8 @@ ngx_http_ssi_header_filter(ngx_http_request_t *r)
}
- if (!(ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_ssi_ctx_t)))) {
+ ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_ssi_ctx_t));
+ if (ctx == NULL) {
return NGX_ERROR;
}
@@ -262,7 +265,7 @@ ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
ctx = ngx_http_get_module_ctx(r, ngx_http_ssi_filter_module);
- if (ctx == NULL || (in == NULL && ctx->in == NULL)) {
+ if (ctx == NULL || (in == NULL && ctx->in == NULL && ctx->busy == NULL)) {
return ngx_http_next_body_filter(r, in);
}
@@ -279,19 +282,21 @@ ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http ssi filter");
- b = NULL;
+ while (ctx->in || ctx->buf) {
- while (ctx->in) {
-
- ctx->buf = ctx->in->buf;
- ctx->in = ctx->in->next;
- ctx->pos = ctx->buf->pos;
+ if (ctx->buf == NULL ){
+ ctx->buf = ctx->in->buf;
+ ctx->in = ctx->in->next;
+ ctx->pos = ctx->buf->pos;
+ }
if (ctx->state == ssi_start_state) {
ctx->copy_start = ctx->pos;
ctx->copy_end = ctx->pos;
}
+ b = NULL;
+
while (ctx->pos < ctx->buf->last) {
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -313,32 +318,60 @@ ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
"saved: %d", ctx->saved);
if (ctx->saved) {
- if (!(b = ngx_calloc_buf(r->pool))) {
- return NGX_ERROR;
+
+ if (ctx->free) {
+ cl = ctx->free;
+ ctx->free = ctx->free->next;
+ b = cl->buf;
+ ngx_memzero(b, sizeof(ngx_buf_t));
+
+ } else {
+ b = ngx_calloc_buf(r->pool);
+ if (b == NULL) {
+ return NGX_ERROR;
+ }
+
+ cl = ngx_alloc_chain_link(r->pool);
+ if (cl == NULL) {
+ return NGX_ERROR;
+ }
+
+ cl->buf = b;
}
b->memory = 1;
b->pos = ngx_http_ssi_string;
b->last = ngx_http_ssi_string + ctx->saved;
- if (!(cl = ngx_alloc_chain_link(r->pool))) {
- return NGX_ERROR;
- }
-
- cl->buf = b;
*ctx->last_out = cl;
ctx->last_out = &cl->next;
ctx->saved = 0;
}
- if (!(b = ngx_calloc_buf(r->pool))) {
- return NGX_ERROR;
+ if (ctx->free) {
+ cl = ctx->free;
+ ctx->free = ctx->free->next;
+ b = cl->buf;
+
+ } else {
+ b = ngx_alloc_buf(r->pool);
+ if (b == NULL) {
+ return NGX_ERROR;
+ }
+
+ cl = ngx_alloc_chain_link(r->pool);
+ if (cl == NULL) {
+ return NGX_ERROR;
+ }
+
+ cl->buf = b;
}
ngx_memcpy(b, ctx->buf, sizeof(ngx_buf_t));
b->last_buf = 0;
+ b->recycled = 0;
b->pos = ctx->copy_start;
b->last = ctx->copy_end;
@@ -353,11 +386,6 @@ ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
}
}
- if (!(cl = ngx_alloc_chain_link(r->pool))) {
- return NGX_ERROR;
- }
-
- cl->buf = b;
cl->next = NULL;
*ctx->last_out = cl;
ctx->last_out = &cl->next;
@@ -461,14 +489,30 @@ ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
/* rc == NGX_HTTP_SSI_ERROR */
-ssi_error:
+ ssi_error:
if (conf->silent_errors) {
continue;
}
- if (!(b = ngx_calloc_buf(r->pool))) {
- return NGX_ERROR;
+ if (ctx->free) {
+ cl = ctx->free;
+ ctx->free = ctx->free->next;
+ b = cl->buf;
+ ngx_memzero(b, sizeof(ngx_buf_t));
+
+ } else {
+ b = ngx_calloc_buf(r->pool);
+ if (b == NULL) {
+ return NGX_ERROR;
+ }
+
+ cl = ngx_alloc_chain_link(r->pool);
+ if (cl == NULL) {
+ return NGX_ERROR;
+ }
+
+ cl->buf = b;
}
b->memory = 1;
@@ -476,11 +520,6 @@ ssi_error:
b->last = ngx_http_ssi_error_string
+ sizeof(ngx_http_ssi_error_string) - 1;
- if (!(cl = ngx_alloc_chain_link(r->pool))) {
- return NGX_ERROR;
- }
-
- cl->buf = b;
cl->next = NULL;
*ctx->last_out = cl;
ctx->last_out = &cl->next;
@@ -488,24 +527,85 @@ ssi_error:
continue;
}
- ctx->buf->pos = ctx->buf->last;
+ if (ctx->buf->recycled || ctx->buf->last_buf) {
+ if (b == NULL) {
+
+ if (ctx->free) {
+ cl = ctx->free;
+ ctx->free = ctx->free->next;
+ b = cl->buf;
+ ngx_memzero(b, sizeof(ngx_buf_t));
+
+ } else {
+ b = ngx_calloc_buf(r->pool);
+ if (b == NULL) {
+ return NGX_ERROR;
+ }
+
+ cl = ngx_alloc_chain_link(r->pool);
+ if (cl == NULL) {
+ return NGX_ERROR;
+ }
+
+ cl->buf = b;
+ }
+
+ cl->next = NULL;
+ *ctx->last_out = cl;
+ ctx->last_out = &cl->next;
+ }
- if (b && ctx->buf->last_buf) {
- b->last_buf = 1;
+ b->last_buf = ctx->buf->last_buf;
+ b->flush = ctx->buf->recycled;
+ b->shadow = ctx->buf;
}
+ ctx->buf = NULL;
+
ctx->saved = ctx->looked;
}
- if (ctx->out == NULL) {
+ if (ctx->out == NULL && ctx->busy == NULL) {
return NGX_OK;
}
rc = ngx_http_next_body_filter(r, ctx->out);
+ if (ctx->busy == NULL) {
+ ctx->busy = ctx->out;
+
+ } else {
+ for (cl = ctx->busy; cl->next; cl = cl->next) { /* void */ }
+ cl->next = ctx->out;
+ }
+
ctx->out = NULL;
ctx->last_out = &ctx->out;
+ while (ctx->busy) {
+
+ b = ctx->busy->buf;
+
+ if (ngx_buf_size(b) != 0) {
+ break;
+ }
+
+#if (NGX_HAVE_WRITE_ZEROCOPY)
+ if (b->zerocopy_busy) {
+ break;
+ }
+#endif
+
+ if (b->shadow) {
+ b->shadow->pos = b->shadow->last;
+ }
+
+ cl = ctx->busy;
+ ctx->busy = cl->next;
+ cl->next = ctx->free;
+ ctx->free = cl;
+ }
+
return rc;
}
@@ -530,16 +630,20 @@ ngx_http_ssi_parse(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx)
/* the tight loop */
- for ( /* void */ ; p < last; ch = *(++p)) {
- if (ch != '<') {
- continue;
+ for ( ;; ) {
+ if (ch == '<') {
+ copy_end = p;
+ looked = 1;
+ state = ssi_tag_state;
+
+ goto tag_started;
}
- copy_end = p;
- looked = 1;
- state = ssi_tag_state;
+ if (++p == last) {
+ break;
+ }
- goto tag_started;
+ ch = *p;
}
ctx->pos = p;
@@ -552,7 +656,8 @@ ngx_http_ssi_parse(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx)
return NGX_AGAIN;
-tag_started:
+ tag_started:
+
continue;
}
@@ -715,7 +820,8 @@ tag_started:
break;
default:
- if (!(ctx->param = ngx_array_push(&ctx->params))) {
+ ctx->param = ngx_array_push(&ctx->params);
+ if (ctx->param == NULL) {
return NGX_ERROR;
}
@@ -1041,80 +1147,45 @@ static ngx_int_t
ngx_http_ssi_echo(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
ngx_str_t **params)
{
- u_char ch;
- ngx_uint_t i, n;
- ngx_buf_t *b;
- ngx_str_t *var, *value;
- ngx_chain_t *cl;
- ngx_list_part_t *part;
- ngx_table_elt_t *header;
+ ngx_buf_t *b;
+ ngx_str_t *var, *value;
+ ngx_chain_t *cl;
+ ngx_http_variable_value_t *v;
var = params[NGX_HTTP_SSI_ECHO_VAR];
value = NULL;
- if (var->len > 5 && ngx_strncmp(var->data, "HTTP_", 5) == 0) {
+ v = ngx_http_get_variable(r, var);
- part = &r->headers_in.headers.part;
- header = part->elts;
-
- for (i = 0; /* void */ ; i++) {
-
- if (i >= part->nelts) {
- if (part->next == NULL) {
- break;
- }
-
- part = part->next;
- header = part->elts;
- i = 0;
- }
-
- for (n = 0; n + 5 < var->len && n < header[i].key.len; n++)
- {
- ch = header[i].key.data[n];
-
- if (ch >= 'a' && ch <= 'z') {
- ch &= ~0x20;
+ if (v == NULL) {
+ return NGX_HTTP_SSI_ERROR;
+ }
- } else if (ch == '-') {
- ch = '_';
- }
+ if (v == NGX_HTTP_VARIABLE_NOT_FOUND) {
+ value = params[NGX_HTTP_SSI_ECHO_DEFAULT];
- if (var->data[n + 5] != ch) {
- break;
- }
- }
+ if (value == NULL) {
+ value = &ngx_http_ssi_none;
- if (n + 5 == var->len) {
- value = &header[i].value;
- break;
- }
+ } else if (value->len == 0) {
+ return NGX_OK;
}
- } else if (var->len == sizeof("REMOTE_ADDR") - 1
- && ngx_strncmp(var->data, "REMOTE_ADDR",
- sizeof("REMOTE_ADDR") - 1) == 0)
- {
- value = &r->connection->addr_text;
- }
-
+ } else {
+ value = &v->text;
- if (value == NULL) {
- value = params[NGX_HTTP_SSI_ECHO_DEFAULT];
- }
-
- if (value == NULL) {
- value = &ngx_http_ssi_none;
-
- } else if (value->len == 0) {
- return NGX_OK;
+ if (value->len == 0) {
+ return NGX_OK;
+ }
}
- if (!(b = ngx_calloc_buf(r->pool))) {
+ b = ngx_calloc_buf(r->pool);
+ if (b == NULL) {
return NGX_HTTP_SSI_ERROR;
}
- if (!(cl = ngx_alloc_chain_link(r->pool))) {
+ cl = ngx_alloc_chain_link(r->pool);
+ if (cl == NULL) {
return NGX_HTTP_SSI_ERROR;
}
@@ -1136,7 +1207,8 @@ ngx_http_ssi_create_conf(ngx_conf_t *cf)
{
ngx_http_ssi_conf_t *conf;
- if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssi_conf_t)))) {
+ conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssi_conf_t));
+ if (conf == NULL) {
return NGX_CONF_ERROR;
}
diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c
index 1ff45da60..4f0f96dc0 100644
--- a/src/http/modules/ngx_http_static_handler.c
+++ b/src/http/modules/ngx_http_static_handler.c
@@ -59,7 +59,7 @@ ngx_module_t ngx_http_static_module = {
ngx_http_static_commands, /* module directives */
NGX_HTTP_MODULE, /* module type */
ngx_http_static_init, /* init module */
- NULL /* init child */
+ NULL /* init process */
};
diff --git a/src/http/modules/ngx_http_userid_filter.c b/src/http/modules/ngx_http_userid_filter.c
index aee161b53..ea49f928b 100644
--- a/src/http/modules/ngx_http_userid_filter.c
+++ b/src/http/modules/ngx_http_userid_filter.c
@@ -38,30 +38,29 @@ typedef struct {
static ngx_int_t ngx_http_userid_get_uid(ngx_http_request_t *r,
- ngx_http_userid_ctx_t *ctx,
- ngx_http_userid_conf_t *conf);
+ ngx_http_userid_ctx_t *ctx, ngx_http_userid_conf_t *conf);
static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r,
- ngx_http_userid_ctx_t *ctx,
- ngx_http_userid_conf_t *conf);
+ ngx_http_userid_ctx_t *ctx, ngx_http_userid_conf_t *conf);
static size_t ngx_http_userid_log_uid_got_getlen(ngx_http_request_t *r,
- uintptr_t data);
+ uintptr_t data);
static u_char *ngx_http_userid_log_uid_got(ngx_http_request_t *r, u_char *buf,
- ngx_http_log_op_t *op);
+ ngx_http_log_op_t *op);
static size_t ngx_http_userid_log_uid_set_getlen(ngx_http_request_t *r,
- uintptr_t data);
+ uintptr_t data);
static u_char *ngx_http_userid_log_uid_set(ngx_http_request_t *r, u_char *buf,
- ngx_http_log_op_t *op);
+ ngx_http_log_op_t *op);
static ngx_int_t ngx_http_userid_add_log_formats(ngx_conf_t *cf);
static ngx_int_t ngx_http_userid_init(ngx_cycle_t *cycle);
static void *ngx_http_userid_create_conf(ngx_conf_t *cf);
static char *ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent,
- void *child);
-char *ngx_http_userid_domain(ngx_conf_t *cf, void *post, void *data);
-char *ngx_http_userid_path(ngx_conf_t *cf, void *post, void *data);
-char *ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
-char *ngx_http_userid_p3p(ngx_conf_t *cf, void *post, void *data);
+ void *child);
+static char *ngx_http_userid_domain(ngx_conf_t *cf, void *post, void *data);
+static char *ngx_http_userid_path(ngx_conf_t *cf, void *post, void *data);
+static char *ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf);
+static char *ngx_http_userid_p3p(ngx_conf_t *cf, void *post, void *data);
static uint32_t sequencer_v1 = 1;
@@ -141,7 +140,7 @@ static ngx_command_t ngx_http_userid_commands[] = {
offsetof(ngx_http_userid_conf_t, p3p),
&ngx_http_userid_p3p_p },
- ngx_null_command
+ ngx_null_command
};
@@ -180,7 +179,8 @@ static ngx_http_log_op_name_t ngx_http_userid_log_fmt_ops[] = {
};
-static ngx_int_t ngx_http_userid_filter(ngx_http_request_t *r)
+static ngx_int_t
+ngx_http_userid_filter(ngx_http_request_t *r)
{
ngx_int_t rc;
ngx_http_userid_ctx_t *ctx;
@@ -192,8 +192,14 @@ static ngx_int_t ngx_http_userid_filter(ngx_http_request_t *r)
return ngx_http_next_header_filter(r);
}
- ngx_http_create_ctx(r, ctx, ngx_http_userid_filter_module,
- sizeof(ngx_http_userid_ctx_t), NGX_ERROR);
+
+ ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_userid_ctx_t));
+ if (ctx == NULL) {
+ return NGX_ERROR;
+ }
+
+ ngx_http_set_ctx(r, ctx, ngx_http_userid_filter_module);
+
rc = ngx_http_userid_get_uid(r, ctx, conf);
@@ -215,9 +221,9 @@ static ngx_int_t ngx_http_userid_filter(ngx_http_request_t *r)
}
-static ngx_int_t ngx_http_userid_get_uid(ngx_http_request_t *r,
- ngx_http_userid_ctx_t *ctx,
- ngx_http_userid_conf_t *conf)
+static ngx_int_t
+ngx_http_userid_get_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx,
+ ngx_http_userid_conf_t *conf)
{
u_char *start, *last, *end;
ngx_uint_t i;
@@ -299,9 +305,9 @@ static ngx_int_t ngx_http_userid_get_uid(ngx_http_request_t *r,
}
-static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r,
- ngx_http_userid_ctx_t *ctx,
- ngx_http_userid_conf_t *conf)
+static ngx_int_t
+ngx_http_userid_set_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx,
+ ngx_http_userid_conf_t *conf)
{
u_char *cookie, *p;
size_t len;
@@ -363,7 +369,8 @@ static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r,
len += conf->domain.len;
}
- if (!(cookie = ngx_palloc(r->pool, len))) {
+ cookie = ngx_palloc(r->pool, len);
+ if (cookie == NULL) {
return NGX_ERROR;
}
@@ -392,7 +399,8 @@ static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r,
p = ngx_cpymem(p, conf->path.data, conf->path.len);
- if (!(set_cookie = ngx_list_push(&r->headers_out.headers))) {
+ set_cookie = ngx_list_push(&r->headers_out.headers);
+ if (set_cookie == NULL) {
return NGX_ERROR;
}
@@ -408,7 +416,8 @@ static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r,
return NGX_OK;
}
- if (!(p3p = ngx_list_push(&r->headers_out.headers))) {
+ p3p = ngx_list_push(&r->headers_out.headers);
+ if (p3p == NULL) {
return NGX_ERROR;
}
@@ -420,8 +429,8 @@ static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r,
}
-static size_t ngx_http_userid_log_uid_got_getlen(ngx_http_request_t *r,
- uintptr_t data)
+static size_t
+ngx_http_userid_log_uid_got_getlen(ngx_http_request_t *r, uintptr_t data)
{
ngx_http_userid_ctx_t *ctx;
ngx_http_userid_conf_t *conf;
@@ -438,8 +447,9 @@ static size_t ngx_http_userid_log_uid_got_getlen(ngx_http_request_t *r,
}
-static u_char *ngx_http_userid_log_uid_got(ngx_http_request_t *r, u_char *buf,
- ngx_http_log_op_t *op)
+static u_char *
+ngx_http_userid_log_uid_got(ngx_http_request_t *r, u_char *buf,
+ ngx_http_log_op_t *op)
{
ngx_http_userid_ctx_t *ctx;
ngx_http_userid_conf_t *conf;
@@ -463,8 +473,8 @@ static u_char *ngx_http_userid_log_uid_got(ngx_http_request_t *r, u_char *buf,
}
-static size_t ngx_http_userid_log_uid_set_getlen(ngx_http_request_t *r,
- uintptr_t data)
+static size_t
+ngx_http_userid_log_uid_set_getlen(ngx_http_request_t *r, uintptr_t data)
{
ngx_http_userid_ctx_t *ctx;
ngx_http_userid_conf_t *conf;
@@ -481,8 +491,9 @@ static size_t ngx_http_userid_log_uid_set_getlen(ngx_http_request_t *r,
}
-static u_char *ngx_http_userid_log_uid_set(ngx_http_request_t *r, u_char *buf,
- ngx_http_log_op_t *op)
+static u_char *
+ngx_http_userid_log_uid_set(ngx_http_request_t *r, u_char *buf,
+ ngx_http_log_op_t *op)
{
ngx_http_userid_ctx_t *ctx;
ngx_http_userid_conf_t *conf;
@@ -506,7 +517,8 @@ static u_char *ngx_http_userid_log_uid_set(ngx_http_request_t *r, u_char *buf,
}
-static ngx_int_t ngx_http_userid_add_log_formats(ngx_conf_t *cf)
+static ngx_int_t
+ngx_http_userid_add_log_formats(ngx_conf_t *cf)
{
ngx_http_log_op_name_t *op;
@@ -525,7 +537,8 @@ static ngx_int_t ngx_http_userid_add_log_formats(ngx_conf_t *cf)
}
-static ngx_int_t ngx_http_userid_init(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_http_userid_init(ngx_cycle_t *cycle)
{
ngx_http_next_header_filter = ngx_http_top_header_filter;
ngx_http_top_header_filter = ngx_http_userid_filter;
@@ -534,11 +547,13 @@ static ngx_int_t ngx_http_userid_init(ngx_cycle_t *cycle)
}
-static void *ngx_http_userid_create_conf(ngx_conf_t *cf)
+static void *
+ngx_http_userid_create_conf(ngx_conf_t *cf)
{
ngx_http_userid_conf_t *conf;
- if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_userid_conf_t)))) {
+ conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_userid_conf_t));
+ if (conf == NULL) {
return NGX_CONF_ERROR;
}
@@ -563,8 +578,8 @@ static void *ngx_http_userid_create_conf(ngx_conf_t *cf)
}
-static char *ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent,
- void *child)
+static char *
+ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent, void *child)
{
ngx_http_userid_conf_t *prev = parent;
ngx_http_userid_conf_t *conf = child;
@@ -583,7 +598,8 @@ static char *ngx_http_userid_merge_conf(ngx_conf_t *cf, void *parent,
}
-char *ngx_http_userid_domain(ngx_conf_t *cf, void *post, void *data)
+static char *
+ngx_http_userid_domain(ngx_conf_t *cf, void *post, void *data)
{
ngx_str_t *domain = data;
@@ -596,7 +612,8 @@ char *ngx_http_userid_domain(ngx_conf_t *cf, void *post, void *data)
return NGX_CONF_OK;
}
- if (!(new = ngx_palloc(cf->pool, sizeof("; domain=") - 1 + domain->len))) {
+ new = ngx_palloc(cf->pool, sizeof("; domain=") - 1 + domain->len);
+ if (new == NULL) {
return NGX_CONF_ERROR;
}
@@ -610,13 +627,15 @@ char *ngx_http_userid_domain(ngx_conf_t *cf, void *post, void *data)
}
-char *ngx_http_userid_path(ngx_conf_t *cf, void *post, void *data)
+static char *
+ngx_http_userid_path(ngx_conf_t *cf, void *post, void *data)
{
ngx_str_t *path = data;
u_char *p, *new;
- if (!(new = ngx_palloc(cf->pool, sizeof("; path=") - 1 + path->len))) {
+ new = ngx_palloc(cf->pool, sizeof("; path=") - 1 + path->len);
+ if (new == NULL) {
return NGX_CONF_ERROR;
}
@@ -630,7 +649,8 @@ char *ngx_http_userid_path(ngx_conf_t *cf, void *post, void *data)
}
-char *ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+static char *
+ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_http_userid_conf_t *ucf = conf;
@@ -665,7 +685,8 @@ char *ngx_http_userid_expires(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
-char *ngx_http_userid_p3p(ngx_conf_t *cf, void *post, void *data)
+static char *
+ngx_http_userid_p3p(ngx_conf_t *cf, void *post, void *data)
{
ngx_str_t *p3p = data;
diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c
index e35433b08..061ab9f0e 100644
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -190,7 +190,7 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
for (i = 0; i < p->lcf->x_vars->nelts; i++) {
- if (!(value = ngx_http_get_variable(r, index[i]))) {
+ if (!(value = ngx_http_get_indexed_variable(r, index[i]))) {
continue;
}
@@ -379,7 +379,7 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
if (p->lcf->x_vars) {
for (i = 0; i < p->lcf->x_vars->nelts; i++) {
- if (!(value = ngx_http_get_variable(r, index[i]))) {
+ if (!(value = ngx_http_get_indexed_variable(r, index[i]))) {
continue;
}
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
index 26f1cb416..f9c926091 100644
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -13,18 +13,13 @@
static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static int ngx_cmp_server_names(const void *one, const void *two);
static ngx_int_t ngx_http_add_address(ngx_conf_t *cf,
- ngx_http_in_port_t *in_port,
- ngx_http_listen_t *lscf,
- ngx_http_core_srv_conf_t *cscf);
+ ngx_http_in_port_t *in_port, ngx_http_listen_t *lscf,
+ ngx_http_core_srv_conf_t *cscf);
static ngx_int_t ngx_http_add_names(ngx_conf_t *cf,
- ngx_http_in_addr_t *in_addr,
- ngx_http_core_srv_conf_t *cscf);
-
+ ngx_http_in_addr_t *in_addr, ngx_http_core_srv_conf_t *cscf);
static char *ngx_http_merge_locations(ngx_conf_t *cf,
- ngx_array_t *locations,
- void **loc_conf,
- ngx_http_module_t *module,
- ngx_uint_t ctx_index);
+ ngx_array_t *locations, void **loc_conf, ngx_http_module_t *module,
+ ngx_uint_t ctx_index);
ngx_uint_t ngx_http_max_module;
@@ -38,14 +33,14 @@ ngx_int_t (*ngx_http_top_body_filter) (ngx_http_request_t *r, ngx_chain_t *ch);
static ngx_command_t ngx_http_commands[] = {
- {ngx_string("http"),
- NGX_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
- ngx_http_block,
- 0,
- 0,
- NULL},
+ { ngx_string("http"),
+ NGX_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+ ngx_http_block,
+ 0,
+ 0,
+ NULL },
- ngx_null_command
+ ngx_null_command
};
@@ -62,11 +57,12 @@ ngx_module_t ngx_http_module = {
ngx_http_commands, /* module directives */
NGX_CORE_MODULE, /* module type */
NULL, /* init module */
- NULL /* init child */
+ NULL /* init process */
};
-static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+static char *
+ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
char *rv;
ngx_uint_t mi, m, s, l, p, a, n;
@@ -686,7 +682,8 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
-static int ngx_cmp_server_names(const void *one, const void *two)
+static int
+ngx_cmp_server_names(const void *one, const void *two)
{
ngx_http_server_name_t *first = (ngx_http_server_name_t *) one;
ngx_http_server_name_t *second = (ngx_http_server_name_t *) two;
@@ -700,10 +697,9 @@ static int ngx_cmp_server_names(const void *one, const void *two)
* configurations to the port (in_port)
*/
-static ngx_int_t ngx_http_add_address(ngx_conf_t *cf,
- ngx_http_in_port_t *in_port,
- ngx_http_listen_t *lscf,
- ngx_http_core_srv_conf_t *cscf)
+static ngx_int_t
+ngx_http_add_address(ngx_conf_t *cf, ngx_http_in_port_t *in_port,
+ ngx_http_listen_t *lscf, ngx_http_core_srv_conf_t *cscf)
{
ngx_http_in_addr_t *in_addr;
@@ -744,9 +740,9 @@ static ngx_int_t ngx_http_add_address(ngx_conf_t *cf,
* configurations to the address:port (in_addr)
*/
-static ngx_int_t ngx_http_add_names(ngx_conf_t *cf,
- ngx_http_in_addr_t *in_addr,
- ngx_http_core_srv_conf_t *cscf)
+static ngx_int_t
+ngx_http_add_names(ngx_conf_t *cf, ngx_http_in_addr_t *in_addr,
+ ngx_http_core_srv_conf_t *cscf)
{
ngx_uint_t i, n;
ngx_array_t *array;
@@ -800,11 +796,9 @@ static ngx_int_t ngx_http_add_names(ngx_conf_t *cf,
}
-static char *ngx_http_merge_locations(ngx_conf_t *cf,
- ngx_array_t *locations,
- void **loc_conf,
- ngx_http_module_t *module,
- ngx_uint_t ctx_index)
+static char *
+ngx_http_merge_locations(ngx_conf_t *cf, ngx_array_t *locations,
+ void **loc_conf, ngx_http_module_t *module, ngx_uint_t ctx_index)
{
char *rv;
ngx_uint_t i;
diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h
index a21c6709f..6f19af1c8 100644
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -29,6 +29,7 @@ typedef struct ngx_http_in_addr_s ngx_http_in_addr_t;
#include <ngx_http_busy_lock.h>
#include <ngx_http_log_handler.h>
#include <ngx_http_core_module.h>
+#include <ngx_http_variables.h>
#if (NGX_HTTP_SSL)
#include <ngx_http_ssl_module.h>
@@ -41,9 +42,9 @@ struct ngx_http_log_ctx_s {
};
-#define ngx_http_get_module_ctx(r, module) r->ctx[module.ctx_index]
+#define ngx_http_get_module_ctx(r, module) (r)->ctx[module.ctx_index]
#define ngx_http_get_module_err_ctx(r, module) \
- (r->err_ctx ? r->err_ctx[module.ctx_index] : r->ctx[module.ctx_index])
+ ((r)->err_ctx ? (r)->err_ctx[module.ctx_index] : (r)->ctx[module.ctx_index])
/* STUB */
#define ngx_http_create_ctx(r, cx, module, size, error) \
@@ -53,11 +54,9 @@ struct ngx_http_log_ctx_s {
} while (0)
/**/
-#define ngx_http_set_ctx(r, c, module) \
- r->ctx[module.ctx_index] = c;
+#define ngx_http_set_ctx(r, c, module) r->ctx[module.ctx_index] = c;
-#define ngx_http_delete_ctx(r, module) \
- r->ctx[module.ctx_index] = NULL;
+#define ngx_http_delete_ctx(r, module) r->ctx[module.ctx_index] = NULL;
void ngx_http_init_connection(ngx_connection_t *c);
@@ -79,10 +78,11 @@ void ngx_http_close_connection(ngx_connection_t *c);
ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
- ngx_http_client_body_handler_pt post_handler);
+ ngx_http_client_body_handler_pt post_handler);
ngx_int_t ngx_http_send_header(ngx_http_request_t *r);
-ngx_int_t ngx_http_special_response_handler(ngx_http_request_t *r, int error);
+ngx_int_t ngx_http_special_response_handler(ngx_http_request_t *r,
+ ngx_int_t error);
time_t ngx_http_parse_time(u_char *value, size_t len);
diff --git a/src/http/ngx_http_config.h b/src/http/ngx_http_config.h
index 85be911a6..0bf63385c 100644
--- a/src/http/ngx_http_config.h
+++ b/src/http/ngx_http_config.h
@@ -48,9 +48,10 @@ typedef struct {
#define NGX_HTTP_LOC_CONF_OFFSET offsetof(ngx_http_conf_ctx_t, loc_conf)
-#define ngx_http_get_module_main_conf(r, module) r->main_conf[module.ctx_index]
-#define ngx_http_get_module_srv_conf(r, module) r->srv_conf[module.ctx_index]
-#define ngx_http_get_module_loc_conf(r, module) r->loc_conf[module.ctx_index]
+#define ngx_http_get_module_main_conf(r, module) \
+ (r)->main_conf[module.ctx_index]
+#define ngx_http_get_module_srv_conf(r, module) (r)->srv_conf[module.ctx_index]
+#define ngx_http_get_module_loc_conf(r, module) (r)->loc_conf[module.ctx_index]
/*
* ngx_http_conf_get_module_srv_conf() and ngx_http_conf_get_module_loc_conf()
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index b3c1a1490..c773d8ff4 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -55,6 +55,7 @@ static char *ngx_http_core_keepalive(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
static char *ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data);
+static ngx_int_t ngx_http_core_init(ngx_cycle_t *cycle);
static ngx_conf_post_t ngx_http_core_lowat_post =
{ ngx_http_core_lowat_check };
@@ -355,7 +356,7 @@ ngx_module_t ngx_http_core_module = {
&ngx_http_core_module_ctx, /* module context */
ngx_http_core_commands, /* module directives */
NGX_HTTP_MODULE, /* module type */
- NULL, /* init module */
+ ngx_http_core_init, /* init module */
NULL /* init process */
};
@@ -984,54 +985,6 @@ ngx_http_delay_handler(ngx_http_request_t *r)
#endif
-ngx_http_variable_t *
-ngx_http_add_variable(ngx_conf_t *cf)
-{
- ngx_http_variable_t *var;
- ngx_http_core_main_conf_t *cmcf;
-
- cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
-
- if (cmcf->variables.elts == NULL) {
- if (ngx_array_init(&cmcf->variables, cf->pool, 5,
- sizeof(ngx_http_variable_t)) == NGX_ERROR)
- {
- return NULL;
- }
- }
-
- if (!(var = ngx_array_push(&cmcf->variables))) {
- return NULL;
- }
-
- var->index = cmcf->variables.nelts - 1;
-
- return var;
-}
-
-
-ngx_http_variable_value_t *
-ngx_http_get_variable(ngx_http_request_t *r, ngx_uint_t index)
-{
- ngx_http_variable_t *v;
- ngx_http_core_main_conf_t *cmcf;
-
- /* TODO: cached variables */
-
- cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
-
- if (cmcf->variables.elts == NULL || cmcf->variables.nelts <= index) {
- ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
- "unknown variable index: %d", index);
- return NULL;
- }
-
- v = cmcf->variables.elts;
-
- return v[index].handler(r, v[index].data);
-}
-
-
static char *
ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
{
@@ -1381,7 +1334,7 @@ ngx_http_core_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
}
for (i = 0; i < NGX_HTTP_TYPES_HASH_PRIME; i++) {
- if (ngx_array_init(&lcf->types[i], cf->pool, 5,
+ if (ngx_array_init(&lcf->types[i], cf->pool, 4,
sizeof(ngx_http_type_t)) == NGX_ERROR)
{
return NGX_CONF_ERROR;
@@ -1415,7 +1368,7 @@ ngx_http_core_create_main_conf(ngx_conf_t *cf)
return NGX_CONF_ERROR;
}
- if (ngx_array_init(&cmcf->servers, cf->pool, 5,
+ if (ngx_array_init(&cmcf->servers, cf->pool, 4,
sizeof(ngx_http_core_srv_conf_t *)) == NGX_ERROR)
{
return NGX_CONF_ERROR;
@@ -1460,19 +1413,19 @@ ngx_http_core_create_srv_conf(ngx_conf_t *cf)
* conf->client_large_buffers.num = 0;
*/
- if (ngx_array_init(&cscf->locations, cf->pool, 5, sizeof(void *))
+ if (ngx_array_init(&cscf->locations, cf->pool, 4, sizeof(void *))
== NGX_ERROR)
{
return NGX_CONF_ERROR;
}
- if (ngx_array_init(&cscf->listen, cf->pool, 5, sizeof(ngx_http_listen_t))
+ if (ngx_array_init(&cscf->listen, cf->pool, 4, sizeof(ngx_http_listen_t))
== NGX_ERROR)
{
return NGX_CONF_ERROR;
}
- if (ngx_array_init(&cscf->server_names, cf->pool, 5,
+ if (ngx_array_init(&cscf->server_names, cf->pool, 4,
sizeof(ngx_http_server_name_t)) == NGX_ERROR)
{
return NGX_CONF_ERROR;
@@ -1654,7 +1607,7 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
}
for (i = 0; i < NGX_HTTP_TYPES_HASH_PRIME; i++) {
- if (ngx_array_init(&conf->types[i], cf->pool, 5,
+ if (ngx_array_init(&conf->types[i], cf->pool, 4,
sizeof(ngx_http_type_t)) == NGX_ERROR)
{
return NGX_CONF_ERROR;
@@ -2063,3 +2016,10 @@ ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data)
return NGX_CONF_OK;
}
+
+
+static ngx_int_t
+ngx_http_core_init(ngx_cycle_t *cycle)
+{
+ return ngx_http_core_variables_init(cycle);
+}
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index dbaef6f34..f8c601790 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -37,27 +37,6 @@ typedef enum {
typedef struct {
- ngx_uint_t value;
- ngx_str_t text;
-} ngx_http_variable_value_t;
-
-
-typedef struct ngx_http_variable_s ngx_http_variable_t;
-
-typedef ngx_http_variable_value_t
- *(*ngx_http_get_variable_pt) (ngx_http_request_t *r, void *var);
-
-
-struct ngx_http_variable_s {
- ngx_str_t name;
- ngx_uint_t index;
- ngx_http_get_variable_pt handler;
- void *data;
- ngx_uint_t uses;
-};
-
-
-typedef struct {
ngx_array_t handlers;
ngx_int_t type; /* NGX_OK, NGX_DECLINED */
} ngx_http_phase_t;
@@ -250,16 +229,12 @@ ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r);
ngx_int_t ngx_http_set_exten(ngx_http_request_t *r);
ngx_int_t ngx_http_internal_redirect(ngx_http_request_t *r,
- ngx_str_t *uri, ngx_str_t *args);
-
-ngx_http_variable_t *ngx_http_add_variable(ngx_conf_t *cf);
-ngx_http_variable_value_t *ngx_http_get_variable(ngx_http_request_t *r,
- ngx_uint_t index);
+ ngx_str_t *uri, ngx_str_t *args);
typedef ngx_int_t (*ngx_http_output_header_filter_pt)(ngx_http_request_t *r);
typedef ngx_int_t (*ngx_http_output_body_filter_pt)
- (ngx_http_request_t *r, ngx_chain_t *chain);
+ (ngx_http_request_t *r, ngx_chain_t *chain);
ngx_int_t ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *chain);
diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c
index ea0907ff1..65d8dee0a 100644
--- a/src/http/ngx_http_header_filter.c
+++ b/src/http/ngx_http_header_filter.c
@@ -34,7 +34,7 @@ ngx_module_t ngx_http_header_filter_module = {
NULL, /* module directives */
NGX_HTTP_MODULE, /* module type */
ngx_http_header_filter_init, /* init module */
- NULL /* init child */
+ NULL /* init process */
};
@@ -50,47 +50,68 @@ static ngx_str_t http_codes[] = {
ngx_null_string, /* "204 No Content" */
ngx_null_string, /* "205 Reset Content" */
ngx_string("206 Partial Content"),
- ngx_null_string, /* "207 Multi-Status" */
-#if 0
- ngx_null_string, /* "300 Multiple Choices" */
-#endif
+ /* ngx_null_string, */ /* "207 Multi-Status" */
+
+#define NGX_HTTP_LEVEL_200 7
+
+ /* ngx_null_string, */ /* "300 Multiple Choices" */
ngx_string("301 Moved Permanently"),
-#if 0
ngx_string("302 Moved Temporarily"),
-#else
- ngx_string("302 Found"),
-#endif
ngx_null_string, /* "303 See Other" */
ngx_string("304 Not Modified"),
+ /* ngx_null_string, */ /* "305 Use Proxy" */
+ /* ngx_null_string, */ /* "306 unused" */
+ /* ngx_null_string, */ /* "307 Temporary Redirect" */
+
+#define NGX_HTTP_LEVEL_300 4
+
ngx_string("400 Bad Request"),
ngx_string("401 Unauthorized"),
- ngx_null_string, /* "402 Payment Required" */
+ ngx_string("402 Payment Required"),
ngx_string("403 Forbidden"),
ngx_string("404 Not Found"),
ngx_string("405 Not Allowed"),
- ngx_null_string, /* "406 Not Acceptable" */
+ ngx_string("406 Not Acceptable"),
ngx_null_string, /* "407 Proxy Authentication Required" */
ngx_string("408 Request Time-out"),
ngx_null_string, /* "409 Conflict" */
- ngx_null_string, /* "410 Gone" */
+ ngx_string("410 Gone"),
ngx_string("411 Length Required"),
ngx_null_string, /* "412 Precondition Failed" */
ngx_string("413 Request Entity Too Large"),
- ngx_null_string, /* "414 Request-URI Too Large" but we never send it
+ ngx_null_string, /* "414 Request-URI Too Large", but we never send it
* because we treat such requests as the HTTP/0.9
* requests and send only a body without a header
*/
ngx_null_string, /* "415 Unsupported Media Type" */
ngx_string("416 Requested Range Not Satisfiable"),
+ /* ngx_null_string, */ /* "417 Expectation Failed" */
+ /* ngx_null_string, */ /* "418 unused" */
+ /* ngx_null_string, */ /* "419 unused" */
+ /* ngx_null_string, */ /* "420 unused" */
+ /* ngx_null_string, */ /* "421 unused" */
+ /* ngx_null_string, */ /* "422 Unprocessable Entity" */
+ /* ngx_null_string, */ /* "423 Locked" */
+ /* ngx_null_string, */ /* "424 Failed Dependency" */
+
+#define NGX_HTTP_LEVEL_400 17
+
ngx_string("500 Internal Server Error"),
ngx_string("501 Method Not Implemented"),
ngx_string("502 Bad Gateway"),
ngx_string("503 Service Temporarily Unavailable"),
ngx_string("504 Gateway Time-out")
+
+ /* ngx_null_string, */ /* "505 HTTP Version Not Supported" */
+ /* ngx_null_string, */ /* "506 Variant Also Negotiates" */
+ /* ngx_null_string, */ /* "507 Insufficient Storage" */
+ /* ngx_null_string, */ /* "508 unused" */
+ /* ngx_null_string, */ /* "509 unused" */
+ /* ngx_null_string, */ /* "510 Not Extended" */
};
@@ -98,19 +119,19 @@ ngx_http_header_t ngx_http_headers_out[] = {
{ ngx_string("Server"), offsetof(ngx_http_headers_out_t, server) },
{ ngx_string("Date"), offsetof(ngx_http_headers_out_t, date) },
{ ngx_string("Content-Type"),
- offsetof(ngx_http_headers_out_t, content_type) },
+ offsetof(ngx_http_headers_out_t, content_type) },
{ ngx_string("Content-Length"),
- offsetof(ngx_http_headers_out_t, content_length) },
+ offsetof(ngx_http_headers_out_t, content_length) },
{ ngx_string("Content-Encoding"),
- offsetof(ngx_http_headers_out_t, content_encoding) },
+ offsetof(ngx_http_headers_out_t, content_encoding) },
{ ngx_string("Location"), offsetof(ngx_http_headers_out_t, location) },
{ ngx_string("Last-Modified"),
- offsetof(ngx_http_headers_out_t, last_modified) },
+ offsetof(ngx_http_headers_out_t, last_modified) },
{ ngx_string("Accept-Ranges"),
- offsetof(ngx_http_headers_out_t, accept_ranges) },
+ offsetof(ngx_http_headers_out_t, accept_ranges) },
{ ngx_string("Expires"), offsetof(ngx_http_headers_out_t, expires) },
{ ngx_string("Cache-Control"),
- offsetof(ngx_http_headers_out_t, cache_control) },
+ offsetof(ngx_http_headers_out_t, cache_control) },
{ ngx_string("ETag"), offsetof(ngx_http_headers_out_t, etag) },
{ ngx_null_string, 0 }
@@ -167,7 +188,8 @@ ngx_http_header_filter(ngx_http_request_t *r)
} else if (r->headers_out.status < NGX_HTTP_BAD_REQUEST) {
/* 3XX */
- status = r->headers_out.status - NGX_HTTP_MOVED_PERMANENTLY + 8;
+ status = r->headers_out.status - NGX_HTTP_MOVED_PERMANENTLY
+ + NGX_HTTP_LEVEL_200;
if (r->headers_out.status == NGX_HTTP_NOT_MODIFIED) {
r->header_only = 1;
@@ -175,12 +197,16 @@ ngx_http_header_filter(ngx_http_request_t *r)
} else if (r->headers_out.status < NGX_HTTP_INTERNAL_SERVER_ERROR) {
/* 4XX */
- status = r->headers_out.status - NGX_HTTP_BAD_REQUEST + 8 + 4;
+ status = r->headers_out.status - NGX_HTTP_BAD_REQUEST
+ + NGX_HTTP_LEVEL_200
+ + NGX_HTTP_LEVEL_300;
} else {
/* 5XX */
- status = r->headers_out.status
- - NGX_HTTP_INTERNAL_SERVER_ERROR + 8 + 4 + 17;
+ status = r->headers_out.status - NGX_HTTP_INTERNAL_SERVER_ERROR
+ + NGX_HTTP_LEVEL_200
+ + NGX_HTTP_LEVEL_300
+ + NGX_HTTP_LEVEL_400;
}
len += http_codes[status].len;
diff --git a/src/http/ngx_http_log_handler.c b/src/http/ngx_http_log_handler.c
index 5a3efe2ba..4cb4af703 100644
--- a/src/http/ngx_http_log_handler.c
+++ b/src/http/ngx_http_log_handler.c
@@ -119,7 +119,7 @@ ngx_module_t ngx_http_log_module = {
ngx_http_log_commands, /* module directives */
NGX_HTTP_MODULE, /* module type */
NULL, /* init module */
- NULL /* init child */
+ NULL /* init process */
};
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index dd104d453..d41cb8d40 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -93,7 +93,6 @@ ngx_http_header_t ngx_http_headers_in[] = {
{ ngx_string("Accept"), offsetof(ngx_http_headers_in_t, accept) },
{ ngx_string("Accept-Language"),
offsetof(ngx_http_headers_in_t, accept_language) },
- { ngx_string("Via"), offsetof(ngx_http_headers_in_t, via) },
#endif
{ ngx_null_string, 0 }
@@ -394,7 +393,7 @@ static void ngx_http_init_request(ngx_event_t *rev)
return;
}
- if (ngx_array_init(&r->cleanup, r->pool, 5, sizeof(ngx_http_cleanup_t))
+ if (ngx_array_init(&r->cleanup, r->pool, 4, sizeof(ngx_http_cleanup_t))
== NGX_ERROR)
{
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
@@ -642,7 +641,7 @@ static void ngx_http_process_request_line(ngx_event_t *rev)
}
- if (ngx_array_init(&r->headers_in.cookies, r->pool, 5,
+ if (ngx_array_init(&r->headers_in.cookies, r->pool, 2,
sizeof(ngx_table_elt_t *)) == NGX_ERROR)
{
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
index a26937497..572ad0a9b 100644
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -51,6 +51,22 @@ static char error_400_page[] =
;
+static char error_401_page[] =
+"<html>" CRLF
+"<head><title>401 Unauthorized</title></head>" CRLF
+"<body bgcolor=\"white\">" CRLF
+"<center><h1>401 Unauthorized</h1></center>" CRLF
+;
+
+
+static char error_402_page[] =
+"<html>" CRLF
+"<head><title>402 Payment Required</title></head>" CRLF
+"<body bgcolor=\"white\">" CRLF
+"<center><h1>402 Payment Required</h1></center>" CRLF
+;
+
+
static char error_403_page[] =
"<html>" CRLF
"<head><title>403 Forbidden</title></head>" CRLF
@@ -75,6 +91,14 @@ static char error_405_page[] =
;
+static char error_406_page[] =
+"<html>" CRLF
+"<head><title>406 Not Acceptable</title></head>" CRLF
+"<body bgcolor=\"white\">" CRLF
+"<center><h1>406 Not Acceptable</h1></center>" CRLF
+;
+
+
static char error_408_page[] =
"<html>" CRLF
"<head><title>408 Request Time-out</title></head>" CRLF
@@ -83,6 +107,14 @@ static char error_408_page[] =
;
+static char error_410_page[] =
+"<html>" CRLF
+"<head><title>410 Gone</title></head>" CRLF
+"<body bgcolor=\"white\">" CRLF
+"<center><h1>410 Gone</h1></center>" CRLF
+;
+
+
static char error_413_page[] =
"<html>" CRLF
"<head><title>413 Request Entity Too Large</title></head>" CRLF
@@ -158,22 +190,25 @@ static char error_504_page[] =
static ngx_str_t error_pages[] = {
- /* ngx_null_string, */ /* 300 */
+
+ /* ngx_null_string, */ /* 300 */
ngx_string(error_301_page),
ngx_string(error_302_page),
ngx_null_string, /* 303 */
+#define NGX_HTTP_LEVEL_300 3
+
ngx_string(error_400_page),
- ngx_null_string, /* 401 */
- ngx_null_string, /* 402 */
+ ngx_string(error_401_page),
+ ngx_string(error_402_page),
ngx_string(error_403_page),
ngx_string(error_404_page),
ngx_string(error_405_page),
- ngx_null_string, /* 406 */
+ ngx_string(error_406_page),
ngx_null_string, /* 407 */
ngx_string(error_408_page),
ngx_null_string, /* 409 */
- ngx_null_string, /* 410 */
+ ngx_string(error_410_page),
ngx_null_string, /* 411 */
ngx_null_string, /* 412 */
ngx_string(error_413_page),
@@ -181,9 +216,11 @@ static ngx_str_t error_pages[] = {
ngx_null_string, /* 415 */
ngx_string(error_416_page),
+#define NGX_HTTP_LEVEL_400 17
+
ngx_string(error_497_page), /* 497, http to https */
ngx_string(error_404_page), /* 498, invalid host name */
- ngx_null_string, /* 499, client closed connection */
+ ngx_null_string, /* 499, client had closed connection */
ngx_string(error_500_page),
ngx_string(error_501_page),
@@ -259,12 +296,12 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
} else if (error < NGX_HTTP_NGX_CODES) {
/* 4XX */
- err = error - NGX_HTTP_BAD_REQUEST + 3;
+ err = error - NGX_HTTP_BAD_REQUEST + NGX_HTTP_LEVEL_300;
} else {
/* 49X, 5XX */
- err = error - NGX_HTTP_NGX_CODES + 3 + 17;
-
+ err = error - NGX_HTTP_NGX_CODES + NGX_HTTP_LEVEL_300
+ + NGX_HTTP_LEVEL_400;
switch (error) {
case NGX_HTTP_TO_HTTPS:
r->headers_out.status = NGX_HTTP_BAD_REQUEST;
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
new file mode 100644
index 000000000..e65f38858
--- /dev/null
+++ b/src/http/ngx_http_variables.c
@@ -0,0 +1,338 @@
+
+/*
+ * Copyright (C) Igor Sysoev
+ */
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+#include <ngx_event.h>
+#include <ngx_http.h>
+
+
+#define NGX_HTTP_VARS_HASH_PRIME 29
+
+#define ngx_http_vars_hash_key(key, vn) \
+ { \
+ ngx_uint_t n; \
+ for (key = 0, n = 0; n < (vn)->len; n++) { \
+ key += (vn)->data[n]; \
+ } \
+ key %= NGX_HTTP_VARS_HASH_PRIME; \
+ }
+
+
+static ngx_http_variable_value_t *
+ ngx_http_variable_header(ngx_http_request_t *r, uintptr_t data);
+static ngx_http_variable_value_t *
+ ngx_http_variable_unknown_header(ngx_http_request_t *r, ngx_str_t *var);
+static ngx_http_variable_value_t *
+ ngx_http_variable_remote_addr(ngx_http_request_t *r, uintptr_t data);
+static ngx_http_variable_value_t *
+ ngx_http_variable_uri(ngx_http_request_t *r, uintptr_t data);
+static ngx_http_variable_value_t *
+ ngx_http_variable_query_string(ngx_http_request_t *r, uintptr_t data);
+
+
+static ngx_array_t *ngx_http_core_variables_hash;
+
+
+static ngx_http_core_variable_t ngx_http_core_variables[] = {
+
+ { ngx_string("HTTP_HOST"), ngx_http_variable_header,
+ offsetof(ngx_http_headers_in_t, host) },
+
+ { ngx_string("HTTP_USER_AGENT"), ngx_http_variable_header,
+ offsetof(ngx_http_headers_in_t, user_agent) },
+
+ { ngx_string("HTTP_REFERER"), ngx_http_variable_header,
+ offsetof(ngx_http_headers_in_t, referer) },
+
+#if (NGX_HTTP_GZIP)
+ { ngx_string("HTTP_VIA"), ngx_http_variable_header,
+ offsetof(ngx_http_headers_in_t, via) },
+#endif
+
+#if (NGX_HTTP_PROXY)
+ { ngx_string("HTTP_X_FORWARDED_FOR"), ngx_http_variable_header,
+ offsetof(ngx_http_headers_in_t, x_forwarded_for) },
+#endif
+
+ { ngx_string("REMOTE_ADDR"), ngx_http_variable_remote_addr, 0 },
+
+ { ngx_string("DOCUMENT_URI"), ngx_http_variable_uri, 0 },
+
+ { ngx_string("QUERY_STRING"), ngx_http_variable_query_string, 0 },
+
+ { ngx_null_string, NULL, 0 }
+};
+
+
+ngx_http_variable_t *
+ngx_http_add_variable(ngx_conf_t *cf)
+{
+ ngx_http_variable_t *var;
+ ngx_http_core_main_conf_t *cmcf;
+
+ cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
+
+ if (cmcf->variables.elts == NULL) {
+ if (ngx_array_init(&cmcf->variables, cf->pool, 4,
+ sizeof(ngx_http_variable_t)) == NGX_ERROR)
+ {
+ return NULL;
+ }
+ }
+
+ if (!(var = ngx_array_push(&cmcf->variables))) {
+ return NULL;
+ }
+
+ var->index = cmcf->variables.nelts - 1;
+
+ return var;
+}
+
+
+ngx_http_variable_value_t *
+ngx_http_get_indexed_variable(ngx_http_request_t *r, ngx_uint_t index)
+{
+ ngx_http_variable_t *var;
+ ngx_http_core_main_conf_t *cmcf;
+
+ /* TODO: cached variables */
+
+ cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
+
+ if (cmcf->variables.elts == NULL || cmcf->variables.nelts <= index) {
+ ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
+ "unknown variable index: %d", index);
+ return NULL;
+ }
+
+ var = cmcf->variables.elts;
+
+ return var[index].handler(r, var[index].data);
+}
+
+
+ngx_int_t
+ngx_http_get_variable_index(ngx_http_core_main_conf_t *cmcf, ngx_str_t *name)
+{
+ ngx_uint_t i;
+ ngx_http_variable_t *var;
+
+ var = cmcf->variables.elts;
+ for (i = 0; i < cmcf->variables.nelts; i++) {
+ if (var[i].name.len != name->len) {
+ continue;
+ }
+
+ if (ngx_strncasecmp(var[i].name.data, name->data, name->len) == 0) {
+ return var[i].index;
+ }
+ }
+
+ return -1;
+}
+
+
+ngx_http_variable_value_t *
+ngx_http_get_variable(ngx_http_request_t *r, ngx_str_t *name)
+{
+ ngx_int_t index;
+ ngx_uint_t i, key;
+ ngx_http_core_variable_t *var;
+ ngx_http_core_main_conf_t *cmcf;
+
+ cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
+
+ index = ngx_http_get_variable_index(cmcf, name);
+
+ if (index != -1) {
+ return ngx_http_get_indexed_variable(r, index);
+ }
+
+ ngx_http_vars_hash_key(key, name);
+
+ var = ngx_http_core_variables_hash[key].elts;
+ for (i = 0; i < ngx_http_core_variables_hash[key].nelts; i++) {
+
+ if (var[i].name.len != name->len
+ || ngx_strncasecmp(var[i].name.data, name->data, name->len) != 0)
+ {
+ continue;
+ }
+
+ return var[i].handler(r, var[i].data);
+ }
+
+ if (ngx_strncasecmp(name->data, "HTTP_", 5) != 0) {
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "unknown \"%V\" variable", name);
+ return NGX_HTTP_VARIABLE_NOT_FOUND;
+ }
+
+ return ngx_http_variable_unknown_header(r, name);
+}
+
+
+static ngx_http_variable_value_t *
+ngx_http_variable_header(ngx_http_request_t *r, uintptr_t data)
+{
+ ngx_table_elt_t *h;
+ ngx_http_variable_value_t *v;
+
+ h = *(ngx_table_elt_t **) ((char *) &r->headers_in + data);
+
+ if (h == NULL) {
+ return NGX_HTTP_VARIABLE_NOT_FOUND;
+ }
+
+ if (!(v = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)))) {
+ return NULL;
+ }
+
+ v->value = 0;
+ v->text = h->value;
+
+ return v;
+}
+
+
+static ngx_http_variable_value_t *
+ngx_http_variable_unknown_header(ngx_http_request_t *r, ngx_str_t *var)
+{
+ u_char ch;
+ ngx_uint_t i, n;
+ ngx_list_part_t *part;
+ ngx_table_elt_t *header;
+ ngx_http_variable_value_t *v;
+
+ part = &r->headers_in.headers.part;
+ header = part->elts;
+
+ for (i = 0; /* void */ ; i++) {
+
+ if (i >= part->nelts) {
+ if (part->next == NULL) {
+ break;
+ }
+
+ part = part->next;
+ header = part->elts;
+ i = 0;
+ }
+
+ for (n = 0; n + 5 < var->len && n < header[i].key.len; n++)
+ {
+ ch = header[i].key.data[n];
+
+ if (ch >= 'a' && ch <= 'z') {
+ ch &= ~0x20;
+
+ } else if (ch == '-') {
+ ch = '_';
+ }
+
+ if (var->data[n + 5] != ch) {
+ break;
+ }
+ }
+
+ if (n + 5 == var->len) {
+ if (!(v = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)))) {
+ return NULL;
+ }
+
+ v->value = 0;
+ v->text = header[i].value;
+ return v;
+ }
+ }
+
+ return NGX_HTTP_VARIABLE_NOT_FOUND;
+}
+
+
+static ngx_http_variable_value_t *
+ngx_http_variable_remote_addr(ngx_http_request_t *r, uintptr_t data)
+{
+ ngx_http_variable_value_t *v;
+
+ if (!(v = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)))) {
+ return NULL;
+ }
+
+ v->value = 0;
+ v->text = r->connection->addr_text;
+
+ return v;
+}
+
+
+static ngx_http_variable_value_t *
+ngx_http_variable_uri(ngx_http_request_t *r, uintptr_t data)
+{
+ ngx_http_variable_value_t *v;
+
+ if (!(v = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)))) {
+ return NULL;
+ }
+
+ v->value = 0;
+ v->text = r->uri;
+
+ return v;
+}
+
+
+static ngx_http_variable_value_t *
+ngx_http_variable_query_string(ngx_http_request_t *r, uintptr_t data)
+{
+ ngx_http_variable_value_t *v;
+
+ if (!(v = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)))) {
+ return NULL;
+ }
+
+ v->value = 0;
+ v->text = r->args;
+
+ return v;
+}
+
+
+ngx_int_t
+ngx_http_core_variables_init(ngx_cycle_t *cycle)
+{
+ ngx_uint_t i, key;
+ ngx_http_core_variable_t *var, *v;
+
+ ngx_http_core_variables_hash = ngx_palloc(cycle->pool,
+ NGX_HTTP_VARS_HASH_PRIME
+ * sizeof(ngx_array_t));
+ if (ngx_http_core_variables_hash == NULL) {
+ return NGX_ERROR;
+ }
+
+ for (i = 0; i < NGX_HTTP_VARS_HASH_PRIME; i++) {
+ if (ngx_array_init(&ngx_http_core_variables_hash[i], cycle->pool, 4,
+ sizeof(ngx_http_core_variable_t)) == NGX_ERROR)
+ {
+ return NGX_ERROR;
+ }
+ }
+
+ for (var = ngx_http_core_variables; var->name.len; var++) {
+ ngx_http_vars_hash_key(key, &var->name);
+
+ if (!(v = ngx_array_push(&ngx_http_core_variables_hash[key]))) {
+ return NGX_ERROR;
+ }
+
+ *v = *var;
+ }
+
+ return NGX_OK;
+}
diff --git a/src/http/ngx_http_variables.h b/src/http/ngx_http_variables.h
new file mode 100644
index 000000000..c7ccdc12e
--- /dev/null
+++ b/src/http/ngx_http_variables.h
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright (C) Igor Sysoev
+ */
+
+
+#ifndef _NGX_HTTP_VARIABLES_H_INCLUDED_
+#define _NGX_HTTP_VARIABLES_H_INCLUDED_
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+#include <ngx_event.h>
+#include <ngx_http.h>
+
+
+#define NGX_HTTP_VARIABLE_NOT_FOUND (ngx_http_variable_value_t *) -1
+
+
+typedef struct {
+ ngx_uint_t value;
+ ngx_str_t text;
+} ngx_http_variable_value_t;
+
+
+typedef struct ngx_http_variable_s ngx_http_variable_t;
+
+typedef ngx_http_variable_value_t *
+ (*ngx_http_get_variable_pt) (ngx_http_request_t *r, void *var);
+
+
+struct ngx_http_variable_s {
+ ngx_str_t name;
+ ngx_uint_t index;
+ ngx_http_get_variable_pt handler;
+ void *data;
+ ngx_uint_t uses;
+};
+
+
+typedef ngx_http_variable_value_t *
+ (*ngx_http_get_core_variable_pt) (ngx_http_request_t *r, uintptr_t data);
+
+typedef struct {
+ ngx_str_t name;
+ ngx_http_get_core_variable_pt handler;
+ uintptr_t data;
+} ngx_http_core_variable_t;
+
+
+ngx_http_variable_t *ngx_http_add_variable(ngx_conf_t *cf);
+ngx_int_t ngx_http_get_variable_index(ngx_http_core_main_conf_t *cmcf,
+ ngx_str_t *name);
+ngx_http_variable_value_t *ngx_http_get_indexed_variable(ngx_http_request_t *r,
+ ngx_uint_t index);
+ngx_http_variable_value_t *ngx_http_get_variable(ngx_http_request_t *r,
+ ngx_str_t *name);
+ngx_int_t ngx_http_core_variables_init(ngx_cycle_t *cycle);
+
+
+#endif /* _NGX_HTTP_VARIABLES_H_INCLUDED_ */
diff --git a/src/http/ngx_http_write_filter.c b/src/http/ngx_http_write_filter.c
index 759801f53..12699096e 100644
--- a/src/http/ngx_http_write_filter.c
+++ b/src/http/ngx_http_write_filter.c
@@ -44,8 +44,8 @@ ngx_module_t ngx_http_write_filter_module = {
ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
{
- int last;
- off_t size, flush, sent;
+ off_t size, sent;
+ ngx_uint_t last, flush;
ngx_chain_t *cl, *ln, **ll, *chain;
ngx_connection_t *c;
ngx_http_core_loc_conf_t *clcf;
@@ -101,7 +101,7 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
size += ngx_buf_size(cl->buf);
if (cl->buf->flush || cl->buf->recycled) {
- flush = size;
+ flush = 1;
}
if (cl->buf->last_buf) {
@@ -152,7 +152,7 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
size += ngx_buf_size(cl->buf);
if (cl->buf->flush || cl->buf->recycled) {
- flush = size;
+ flush = 1;
}
if (cl->buf->last_buf) {
@@ -165,7 +165,7 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
c = r->connection;
ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0,
- "http write filter: l:%d f:%O s:%O", last, flush, size);
+ "http write filter: l:%d f:%d s:%O", last, flush, size);
clcf = ngx_http_get_module_loc_conf(r->main ? r->main : r,
ngx_http_core_module);
@@ -176,7 +176,7 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
* is smaller than "postpone_output" directive
*/
- if (!last && flush == 0 && in && size < (off_t) clcf->postpone_output) {
+ if (!last && !flush && in && size < (off_t) clcf->postpone_output) {
return NGX_OK;
}
@@ -189,6 +189,11 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
return NGX_OK;
}
+ if (flush) {
+ while ((ctx->out = ctx->out->next)) { /* void */ }
+ return NGX_OK;
+ }
+
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
"the http output chain is empty");
diff --git a/src/os/unix/ngx_daemon.c b/src/os/unix/ngx_daemon.c
index b9a9b404c..7255b7a7e 100644
--- a/src/os/unix/ngx_daemon.c
+++ b/src/os/unix/ngx_daemon.c
@@ -8,7 +8,7 @@
#include <ngx_core.h>
-int ngx_daemon(ngx_log_t *log)
+ngx_int_t ngx_daemon(ngx_log_t *log)
{
int fd;
diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c
index abc7f81f7..4fb512665 100644
--- a/src/os/unix/ngx_posix_init.c
+++ b/src/os/unix/ngx_posix_init.c
@@ -28,7 +28,7 @@ ngx_os_io_t ngx_os_io = {
};
-int ngx_os_init(ngx_log_t *log)
+ngx_int_t ngx_os_init(ngx_log_t *log)
{
return ngx_posix_init(log);
}
@@ -282,7 +282,7 @@ void ngx_signal_handler(int signo)
}
-int ngx_posix_post_conf_init(ngx_log_t *log)
+ngx_int_t ngx_posix_post_conf_init(ngx_log_t *log)
{
ngx_fd_t pp[2];