nginx-0.1.24-RELEASE import

*) 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.
This commit is contained in:
Igor Sysoev 2005-03-04 14:06:57 +00:00
parent 7ad4a94eee
commit 8184d1b3a7
56 changed files with 1229 additions and 628 deletions

View File

@ -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"

View File

@ -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 \

View File

@ -9,6 +9,52 @@
<title lang="en">nginx changelog</title>
<changes ver="0.1.24" date="04.03.2005">
<change type="feature">
<para lang="ru">
ÍÏÄÕÌØ ngx_http_ssi_filter_module ÐÏÄÄÅÒÖÉ×ÁÅÔ ÐÅÒÅÍÅÎÎÙÅ
QUERY_STRING É DOCUMENT_URI.
</para>
<para lang="en">
the ngx_http_ssi_filter_module supports the QUERY_STRING and DOCUMENT_URI
variables.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÍÏÄÕÌØ ngx_http_autoindex_module ÍÏÇ ×ÙÄÁ×ÁÔØ ÏÔ×ÅÔ 404
ÎÁ ÓÕÝÅÓÔ×ÕÀÝÉÊ ËÁÔÁÌÏÇ, ÅÓÌÉ ÜÔÏÔ ËÁÔÁÌÏÇ ÂÙÌ ÕËÁÚÁÎ ËÁË alias.
</para>
<para lang="en">
the ngx_http_autoindex_module may some times return the 404 response
for existent directory, if this directory was used in "alias" directive.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÍÏÄÕÌØ ngx_http_ssi_filter_module ÎÅÐÒÁ×ÉÌØÎÏ ÒÁÂÏÔÁÌ ÐÒÉ ÂÏÌØÛÉÈ
ÏÔ×ÅÔÁÈ.
</para>
<para lang="en">
the ngx_http_ssi_filter_module ran incorrectly for large responses.
</para>
</change>
<change type="bugfix">
<para lang="ru">
ÏÔÓÕÔÓÔ×ÉÅ ÓÔÒÏËÉ ÚÁÇÏÌÏ×ËÁ "Referer" ×ÓÅÇÄÁ ÓÞÉÔÁÌÏÓØ ÐÒÁ×ÉÌØÎÙÍ referrer'ÏÍ.
</para>
<para lang="en">
the lack of the "Referer" header line was always accounted as valid referrer.
</para>
</change>
</changes>
<changes ver="0.1.23" date="01.03.2005">
<change type="feature">

View File

@ -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;

View File

@ -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"

View File

@ -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,
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;
}
}

View File

@ -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 */
};

View File

@ -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__ */

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -10,7 +10,7 @@
typedef struct ngx_gc_s ngx_gc_t;
typedef int (*ngx_gc_handler_pt) (ngx_gc_t *ctx, ngx_str_t *name,
typedef ngx_int_t (*ngx_gc_handler_pt) (ngx_gc_t *ctx, ngx_str_t *name,
ngx_dir_t *dir);
@ -23,7 +23,7 @@ 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);

View File

@ -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;

View File

@ -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;

View File

@ -25,7 +25,8 @@ static ngx_int_t ngx_output_chain_copy_buf(ngx_buf_t *dst, ngx_buf_t *src,
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();
}

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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,19 +52,19 @@ static ngx_str_t devpoll_name = ngx_string("/dev/poll");
static ngx_command_t ngx_devpoll_commands[] = {
{ngx_string("devpoll_changes"),
{ ngx_string("devpoll_changes"),
NGX_EVENT_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
0,
offsetof(ngx_devpoll_conf_t, changes),
NULL},
NULL },
{ngx_string("devpoll_events"),
{ ngx_string("devpoll_events"),
NGX_EVENT_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
0,
offsetof(ngx_devpoll_conf_t, events),
NULL},
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;

View File

@ -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,12 +90,12 @@ static ngx_str_t epoll_name = ngx_string("epoll");
static ngx_command_t ngx_epoll_commands[] = {
{ngx_string("epoll_events"),
{ ngx_string("epoll_events"),
NGX_EVENT_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
0,
offsetof(ngx_epoll_conf_t, events),
NULL},
NULL },
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;

View File

@ -55,19 +55,19 @@ static ngx_str_t kqueue_name = ngx_string("kqueue");
static ngx_command_t ngx_kqueue_commands[] = {
{ngx_string("kqueue_changes"),
{ ngx_string("kqueue_changes"),
NGX_EVENT_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
0,
offsetof(ngx_kqueue_conf_t, changes),
NULL},
NULL },
{ngx_string("kqueue_events"),
{ ngx_string("kqueue_events"),
NGX_EVENT_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
0,
offsetof(ngx_kqueue_conf_t, events),
NULL},
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;

View File

@ -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;

View File

@ -65,33 +65,33 @@ static ngx_conf_num_bounds_t ngx_overflow_threshold_bounds = {
static ngx_command_t ngx_rtsig_commands[] = {
{ngx_string("rtsig_signo"),
{ ngx_string("rtsig_signo"),
NGX_EVENT_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
0,
offsetof(ngx_rtsig_conf_t, signo),
NULL},
NULL },
{ngx_string("rtsig_overflow_events"),
{ 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},
NULL },
{ngx_string("rtsig_overflow_test"),
{ 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},
NULL },
{ngx_string("rtsig_overflow_threshold"),
{ 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_overflow_threshold_bounds },
ngx_null_command
};
@ -127,7 +127,8 @@ ngx_module_t ngx_rtsig_module = {
};
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) {

View File

@ -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

View File

@ -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;

View File

@ -40,8 +40,8 @@ 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,
@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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 */
};

View File

@ -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 */
};

View File

@ -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;

View File

@ -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;
}
index = ngx_http_get_variable_index(cmcf, &value[1]);
if (ngx_strncasecmp(var[i].name.data, value[1].data,
var[i].name.len) == 0)
{
break;
}
}
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));

View File

@ -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) {
while (ctx->in || ctx->buf) {
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))) {
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))) {
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,26 +489,37 @@ 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))) {
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_error_string;
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 (b && ctx->buf->last_buf) {
b->last_buf = 1;
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;
}
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,11 +630,8 @@ 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;
@ -542,6 +639,13 @@ ngx_http_ssi_parse(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx)
goto tag_started;
}
if (++p == last) {
break;
}
ch = *p;
}
ctx->pos = p;
ctx->looked = looked;
ctx->copy_end = 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,67 +1147,22 @@ 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_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;
if (v == NULL) {
return NGX_HTTP_SSI_ERROR;
}
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) {
value = &header[i].value;
break;
}
}
} else if (var->len == sizeof("REMOTE_ADDR") - 1
&& ngx_strncmp(var->data, "REMOTE_ADDR",
sizeof("REMOTE_ADDR") - 1) == 0)
{
value = &r->connection->addr_text;
}
if (value == NULL) {
if (v == NGX_HTTP_VARIABLE_NOT_FOUND) {
value = params[NGX_HTTP_SSI_ECHO_DEFAULT];
}
if (value == NULL) {
value = &ngx_http_ssi_none;
@ -1110,11 +1171,21 @@ ngx_http_ssi_echo(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx,
return NGX_OK;
}
if (!(b = ngx_calloc_buf(r->pool))) {
} else {
value = &v->text;
if (value->len == 0) {
return NGX_OK;
}
}
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;
}

View File

@ -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 */
};

View File

@ -38,11 +38,9 @@ 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);
@ -58,10 +56,11 @@ 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);
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;
@ -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,8 +221,8 @@ 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,
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;
@ -299,8 +305,8 @@ 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,
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;
@ -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,7 +447,8 @@ 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,
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;
@ -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,7 +491,8 @@ 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,
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;
@ -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;

View File

@ -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;
}

View File

@ -13,17 +13,12 @@
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_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_array_t *locations, void **loc_conf, ngx_http_module_t *module,
ngx_uint_t ctx_index);
ngx_uint_t ngx_http_max_module;
@ -38,12 +33,12 @@ 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_string("http"),
NGX_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
ngx_http_block,
0,
0,
NULL},
NULL },
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,8 +740,8 @@ 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,
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;
@ -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;

View File

@ -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);
@ -82,7 +81,8 @@ ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
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);

View File

@ -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()

View File

@ -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);
}

View File

@ -36,27 +36,6 @@ typedef enum {
} ngx_http_phases;
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 */
@ -252,10 +231,6 @@ 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);
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)

View File

@ -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" */
};
@ -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;

View File

@ -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 */
};

View File

@ -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);

View File

@ -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_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;

View File

@ -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;
}

View File

@ -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_ */

View File

@ -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");

View File

@ -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;

View File

@ -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];

View File

@ -174,9 +174,10 @@ ssize_t ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl,
ngx_int_t ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to,
ngx_pool_t *pool)
{
int rc, collision;
u_int num;
u_char *name;
ngx_int_t rc;
ngx_uint_t collision;
ngx_atomic_uint_t num;
if (!(name = ngx_palloc(pool, to->len + 1 + 10 + 1 + sizeof("DELETE")))) {
return NGX_ERROR;
@ -188,18 +189,19 @@ ngx_int_t ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to,
/* mutex_lock() (per cache or single ?) */
do {
for ( ;; ) {
num = ngx_next_temp_number(collision);
ngx_sprintf(name + to->len, ".%010u.DELETE", num);
ngx_sprintf(name + to->len, ".%0muA.DELETE", num);
if (MoveFile((const char *) to->data, (const char *) name) == 0) {
collision = 1;
ngx_log_error(NGX_LOG_ERR, pool->log, ngx_errno,
"MoveFile() failed");
if (MoveFile((const char *) to->data, (const char *) name) != 0) {
break;
}
} while (collision);
collision = 1;
ngx_log_error(NGX_LOG_ERR, pool->log, ngx_errno, "MoveFile() failed");
}
if (MoveFile((const char *) from->data, (const char *) to->data) == 0) {
rc = NGX_ERROR;

View File

@ -40,8 +40,10 @@
/* disable some "-W4" level warnings */
/* disable warnings about some 'type cast */
/* 'type cast': from function pointer to data pointer */
#pragma warning(disable:4054)
/* 'type cast': from data pointer to function pointer */
#pragma warning(disable:4055)
/* unreferenced formal parameter */
@ -56,34 +58,48 @@
/* assignment within conditional expression */
#pragma warning(disable:4706)
/* disable "function 'ngx_handle_write_event' not inlined" */
/* function 'ngx_handle_write_event' not inlined */
#pragma warning(disable:4710)
#endif
#ifdef __WATCOMC__
/* unreachable code */
#pragma disable_message(201)
/* disable "Symbol 'ngx_rbtree_min' has been defined, but not referenced" */
/* symbol 'ngx_rbtree_min' has been defined, but not referenced */
#pragma disable_message(202)
#endif
#ifdef __BORLANDC__
/* the end of the precompiled headers */
#pragma hdrstop
/*
* 'fd' is assigned a value that is never used in function ngx_event_init_conf
*/
#pragma warn -8004
/* condition is always false */
#pragma warn -8008
/* functions containing (for|while|some if) are not expanded inline */
#pragma warn -8027
/* unreferenced formal parameter */
#pragma warn -8057
/* assignment within conditional expression */
#pragma warn -8060
/* STUB */
#pragma warn -8004
#pragma warn -8008
#pragma warn -8065
/* unreachable code */
#pragma warn -8066
#pragma warn -8075
#endif
@ -96,7 +112,8 @@
#ifdef _MSC_VER
typedef unsigned __int32 uint32_t;
typedef __int32 int32_t;
#else /* __WATCOMC__ */
#else /* __WATCOMC__ and __BORLANDC__ */
typedef unsigned int uint32_t;
typedef int int32_t;
#endif