# HG changeset patch # User Igor Sysoev # Date 1087399931 0 # Node ID 2e3cbc1bbe3c8e9385dc353f5e139a3722c10a3e # Parent 0fb6c53fb1352302978322af8369a15c91d03b58 nginx-0.0.7-2004-06-16-19:32:11 import diff --git a/src/core/ngx_buf.c b/src/core/ngx_buf.c --- a/src/core/ngx_buf.c +++ b/src/core/ngx_buf.c @@ -84,7 +84,8 @@ ngx_chain_t *ngx_create_chain_of_bufs(ng } -int 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; diff --git a/src/core/ngx_buf.h b/src/core/ngx_buf.h --- a/src/core/ngx_buf.h +++ b/src/core/ngx_buf.h @@ -170,10 +170,11 @@ ngx_chain_t *ngx_create_chain_of_bufs(ng last = &cl->next -int ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in); -int ngx_chain_writer(void *data, ngx_chain_t *in); +ngx_int_t ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in); +ngx_int_t ngx_chain_writer(void *data, ngx_chain_t *in); -int 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); void ngx_chain_update_chains(ngx_chain_t **free, ngx_chain_t **busy, ngx_chain_t **out, ngx_buf_tag_t tag); diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h --- a/src/core/ngx_conf_file.h +++ b/src/core/ngx_conf_file.h @@ -90,15 +90,15 @@ struct ngx_open_file_s { struct ngx_module_s { - int ctx_index; - int index; + ngx_uint_t ctx_index; + ngx_uint_t index; void *ctx; ngx_command_t *commands; - int type; - int (*init_module)(ngx_cycle_t *cycle); - int (*init_process)(ngx_cycle_t *cycle); + ngx_uint_t type; + ngx_int_t (*init_module)(ngx_cycle_t *cycle); + ngx_int_t (*init_process)(ngx_cycle_t *cycle); #if 0 - int (*init_thread)(ngx_cycle_t *cycle); + ngx_int_t (*init_thread)(ngx_cycle_t *cycle); #endif }; @@ -113,7 +113,7 @@ typedef struct { typedef struct { ngx_file_t file; ngx_buf_t *buffer; - int line; + ngx_uint_t line; } ngx_conf_file_t; @@ -131,8 +131,8 @@ struct ngx_conf_s { ngx_log_t *log; void *ctx; - int module_type; - int cmd_type; + ngx_uint_t module_type; + ngx_uint_t cmd_type; ngx_conf_handler_pt handler; char *handler_conf; diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h --- a/src/core/ngx_config.h +++ b/src/core/ngx_config.h @@ -31,12 +31,6 @@ #endif -/* STUB: autoconf */ -typedef int ngx_int_t; -typedef u_int ngx_uint_t; -typedef int ngx_flag_t; - - #if !(WIN32) #define ngx_signal_helper(n) SIG##n @@ -58,6 +52,26 @@ typedef int ngx_flag_t; #define NGX_INVALID_ARRAY_INDEX 0x80000000 +#if 1 +/* STUB: autoconf */ +typedef int ngx_int_t; +typedef u_int ngx_uint_t; +typedef int ngx_flag_t; +#define NGX_INT_T_LEN sizeof("-2147483648") - 1 +#define NGX_INT_T_FMT "d" +#define NGX_UINT_T_FMT "u" + +#else + +typedef long ngx_int_t; +typedef u_long ngx_uint_t; +typedef long ngx_flag_t; +#define NGX_INT_T_LEN sizeof("-9223372036854775808") - 1 +#define NGX_INT_T_FMT "lld" +#define NGX_UINT_T_FMT "llu" + +#endif + /* TODO: auto */ #define NGX_INT32_LEN sizeof("-2147483648") - 1 #define NGX_INT64_LEN sizeof("-9223372036854775808") - 1 diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h --- a/src/core/ngx_connection.h +++ b/src/core/ngx_connection.h @@ -97,7 +97,7 @@ struct ngx_connection_s { ngx_buf_t *buffer; - ngx_int_t number; + ngx_uint_t number; unsigned log_error:2; /* ngx_connection_log_error_e */ diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c --- a/src/core/ngx_output_chain.c +++ b/src/core/ngx_output_chain.c @@ -7,13 +7,13 @@ #define NGX_NONE 1 -ngx_inline static int ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx, - ngx_buf_t *buf); +ngx_inline static 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_copy_buf(ngx_buf_t *dst, ngx_buf_t *src, ngx_uint_t sendfile); -int 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; size_t size, bsize; @@ -168,8 +168,8 @@ int ngx_output_chain(ngx_output_chain_ct } -ngx_inline static int ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx, - ngx_buf_t *buf) +ngx_inline static ngx_int_t + ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf) { if (ngx_buf_special(buf)) { return 0; diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c --- a/src/event/modules/ngx_kqueue_module.c +++ b/src/event/modules/ngx_kqueue_module.c @@ -16,12 +16,12 @@ typedef struct { } ngx_kqueue_conf_t; -static int ngx_kqueue_init(ngx_cycle_t *cycle); +static ngx_int_t ngx_kqueue_init(ngx_cycle_t *cycle); static void ngx_kqueue_done(ngx_cycle_t *cycle); -static int ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags); -static int ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags); -static int ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags); -static int ngx_kqueue_process_events(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_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_process_events(ngx_cycle_t *cycle); static ngx_inline void ngx_kqueue_dump_event(ngx_log_t *log, struct kevent *kev); @@ -87,7 +87,7 @@ ngx_module_t ngx_kqueue_module = { -static int 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; @@ -184,7 +184,7 @@ static void ngx_kqueue_done(ngx_cycle_t } -static int 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_event_t *e; ngx_connection_t *c; @@ -229,7 +229,7 @@ static int ngx_kqueue_add_event(ngx_even } -static int 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_event_t *e; @@ -276,7 +276,7 @@ static int ngx_kqueue_del_event(ngx_even } -static int 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 timespec ts; ngx_connection_t *c; diff --git a/src/event/modules/ngx_poll_module.c b/src/event/modules/ngx_poll_module.c --- a/src/event/modules/ngx_poll_module.c +++ b/src/event/modules/ngx_poll_module.c @@ -9,11 +9,11 @@ #include -static int ngx_poll_init(ngx_cycle_t *cycle); +static ngx_int_t ngx_poll_init(ngx_cycle_t *cycle); static void ngx_poll_done(ngx_cycle_t *cycle); -static int ngx_poll_add_event(ngx_event_t *ev, int event, u_int flags); -static int ngx_poll_del_event(ngx_event_t *ev, int event, u_int flags); -int ngx_poll_process_events(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_del_event(ngx_event_t *ev, int event, u_int flags); +static ngx_int_t ngx_poll_process_events(ngx_cycle_t *cycle); static struct pollfd *event_list; @@ -58,7 +58,7 @@ ngx_module_t ngx_poll_module = { -static int ngx_poll_init(ngx_cycle_t *cycle) +static ngx_int_t ngx_poll_init(ngx_cycle_t *cycle) { struct pollfd *list; @@ -118,7 +118,7 @@ static void ngx_poll_done(ngx_cycle_t *c } -static int 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; @@ -171,7 +171,7 @@ static int ngx_poll_add_event(ngx_event_ } -static int 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; @@ -259,7 +259,7 @@ static int ngx_poll_del_event(ngx_event_ } -int ngx_poll_process_events(ngx_cycle_t *cycle) +static ngx_int_t ngx_poll_process_events(ngx_cycle_t *cycle) { int ready; ngx_int_t i, nready; @@ -272,33 +272,27 @@ int ngx_poll_process_events(ngx_cycle_t ngx_connection_t *c; struct timeval tv; - if (ngx_event_flags & NGX_OVERFLOW_EVENT) { - timer = 0; + for ( ;; ) { + timer = ngx_event_find_timer(); + + if (timer != 0) { + break; + } + + ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, + "poll expired timer"); + + ngx_event_expire_timers((ngx_msec_t) + (ngx_elapsed_msec - ngx_old_elapsed_msec)); + } + + /* NGX_TIMER_INFINITE == INFTIM */ + + if (timer == NGX_TIMER_INFINITE) { expire = 0; } else { - for ( ;; ) { - timer = ngx_event_find_timer(); - - if (timer != 0) { - break; - } - - ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, - "poll expired timer"); - - ngx_event_expire_timers((ngx_msec_t) - (ngx_elapsed_msec - ngx_old_elapsed_msec)); - } - - /* NGX_TIMER_INFINITE == INFTIM */ - - if (timer == NGX_TIMER_INFINITE) { - expire = 0; - - } else { - expire = 1; - } + expire = 1; } ngx_old_elapsed_msec = ngx_elapsed_msec; @@ -372,14 +366,6 @@ int ngx_poll_process_events(ngx_cycle_t } } - if ((ngx_event_flags & NGX_OVERFLOW_EVENT) && timer == 0 && ready == 0) { - - /* the overflowed rt signals queue has been drained */ - - ngx_accept_mutex_unlock(); - return NGX_OK; - } - if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) { ngx_accept_mutex_unlock(); return NGX_ERROR; diff --git a/src/event/modules/ngx_select_module.c b/src/event/modules/ngx_select_module.c --- a/src/event/modules/ngx_select_module.c +++ b/src/event/modules/ngx_select_module.c @@ -10,11 +10,11 @@ -static int ngx_select_init(ngx_cycle_t *cycle); +static ngx_int_t ngx_select_init(ngx_cycle_t *cycle); static void ngx_select_done(ngx_cycle_t *cycle); -static int ngx_select_add_event(ngx_event_t *ev, int event, u_int flags); -static int ngx_select_del_event(ngx_event_t *ev, int event, u_int flags); -static int ngx_select_process_events(ngx_cycle_t *cycle); +static ngx_int_t ngx_select_add_event(ngx_event_t *ev, int event, u_int flags); +static ngx_int_t ngx_select_del_event(ngx_event_t *ev, int event, u_int flags); +static ngx_int_t ngx_select_process_events(ngx_cycle_t *cycle); static char *ngx_select_init_conf(ngx_cycle_t *cycle, void *conf); @@ -72,7 +72,7 @@ ngx_module_t ngx_select_module = { }; -static int ngx_select_init(ngx_cycle_t *cycle) +static ngx_int_t ngx_select_init(ngx_cycle_t *cycle) { ngx_event_t **index; @@ -135,7 +135,7 @@ static void ngx_select_done(ngx_cycle_t } -static int ngx_select_add_event(ngx_event_t *ev, int event, u_int flags) +static ngx_int_t ngx_select_add_event(ngx_event_t *ev, int event, u_int flags) { ngx_connection_t *c; @@ -196,7 +196,7 @@ static int ngx_select_add_event(ngx_even } -static int ngx_select_del_event(ngx_event_t *ev, int event, u_int flags) +static ngx_int_t ngx_select_del_event(ngx_event_t *ev, int event, u_int flags) { ngx_connection_t *c; @@ -249,7 +249,7 @@ static int ngx_select_del_event(ngx_even } -static int ngx_select_process_events(ngx_cycle_t *cycle) +static ngx_int_t ngx_select_process_events(ngx_cycle_t *cycle) { int ready, nready; ngx_uint_t i, found, lock, expire; diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c --- a/src/event/ngx_event.c +++ b/src/event/ngx_event.c @@ -504,7 +504,7 @@ static char *ngx_event_use(ngx_conf_t *c ngx_event_conf_t *old_ecf; ngx_event_module_t *module; - if (ecf->use != NGX_CONF_UNSET) { + if (ecf->use != NGX_CONF_UNSET_UINT) { return "is duplicate" ; } @@ -633,19 +633,19 @@ static char *ngx_event_init_conf(ngx_cyc #if (HAVE_KQUEUE) ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS); - ngx_conf_init_value(ecf->use, ngx_kqueue_module.ctx_index); + ngx_conf_init_unsigned_value(ecf->use, ngx_kqueue_module.ctx_index); ngx_conf_init_ptr_value(ecf->name, ngx_kqueue_module_ctx.name->data); #elif (HAVE_DEVPOLL) ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS); - ngx_conf_init_value(ecf->use, ngx_devpoll_module.ctx_index); + ngx_conf_init_unsigned_value(ecf->use, ngx_devpoll_module.ctx_index); ngx_conf_init_ptr_value(ecf->name, ngx_devpoll_module_ctx.name->data); #elif (HAVE_EPOLL) ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS); - ngx_conf_init_value(ecf->use, ngx_epoll_module.ctx_index); + ngx_conf_init_unsigned_value(ecf->use, ngx_epoll_module.ctx_index); ngx_conf_init_ptr_value(ecf->name, ngx_epoll_module_ctx.name->data); #elif (HAVE_RTSIG) @@ -653,7 +653,7 @@ static char *ngx_event_init_conf(ngx_cyc ngx_core_conf_t *ccf; ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS); - ngx_conf_init_value(ecf->use, ngx_rtsig_module.ctx_index); + ngx_conf_init_unsigned_value(ecf->use, ngx_rtsig_module.ctx_index); ngx_conf_init_ptr_value(ecf->name, ngx_rtsig_module_ctx.name->data); #elif (HAVE_SELECT) @@ -665,7 +665,7 @@ static char *ngx_event_init_conf(ngx_cyc FD_SETSIZE < DEFAULT_CONNECTIONS ? FD_SETSIZE : DEFAULT_CONNECTIONS); #endif - ngx_conf_init_value(ecf->use, ngx_select_module.ctx_index); + ngx_conf_init_unsigned_value(ecf->use, ngx_select_module.ctx_index); ngx_conf_init_ptr_value(ecf->name, ngx_select_module_ctx.name->data); #else @@ -694,9 +694,9 @@ static char *ngx_event_init_conf(ngx_cyc return NGX_CONF_ERROR; } - ngx_conf_init_value(ecf->connections, DEFAULT_CONNECTIONS); + ngx_conf_unsigned_init_value(ecf->connections, DEFAULT_CONNECTIONS); - ngx_conf_init_value(ecf->use, m); + ngx_conf_unsigned_init_value(ecf->use, m); ngx_conf_init_ptr_value(ecf->name, module->name->data); #endif diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h --- a/src/event/ngx_event.h +++ b/src/event/ngx_event.h @@ -177,18 +177,18 @@ struct ngx_event_s { typedef struct { - int (*add)(ngx_event_t *ev, int event, u_int flags); - int (*del)(ngx_event_t *ev, int event, u_int flags); + ngx_int_t (*add)(ngx_event_t *ev, int event, u_int flags); + ngx_int_t (*del)(ngx_event_t *ev, int event, u_int flags); - int (*enable)(ngx_event_t *ev, int event, u_int flags); - int (*disable)(ngx_event_t *ev, int event, u_int flags); + ngx_int_t (*enable)(ngx_event_t *ev, int event, u_int flags); + ngx_int_t (*disable)(ngx_event_t *ev, int event, u_int flags); - int (*add_conn)(ngx_connection_t *c); - int (*del_conn)(ngx_connection_t *c, u_int flags); + ngx_int_t (*add_conn)(ngx_connection_t *c); + ngx_int_t (*del_conn)(ngx_connection_t *c, u_int flags); - int (*process)(ngx_cycle_t *cycle); - int (*init)(ngx_cycle_t *cycle); - void (*done)(ngx_cycle_t *cycle); + ngx_int_t (*process)(ngx_cycle_t *cycle); + ngx_int_t (*init)(ngx_cycle_t *cycle); + void (*done)(ngx_cycle_t *cycle); } ngx_event_actions_t; @@ -249,21 +249,16 @@ extern ngx_event_actions_t ngx_event_a #define NGX_USE_RTSIG_EVENT 0x00000100 /* - * The alternative event method after the rt signals queue overflow. - */ -#define NGX_OVERFLOW_EVENT 0x00000200 - -/* * No need to add or delete the event filters - overlapped, aio_read, * aioread, io_submit. */ -#define NGX_USE_AIO_EVENT 0x00000400 +#define NGX_USE_AIO_EVENT 0x00000200 /* * Need to add socket or handle only once - i/o completion port. * It also requires HAVE_AIO and NGX_USE_AIO_EVENT to be set. */ -#define NGX_USE_IOCP_EVENT 0x00000800 +#define NGX_USE_IOCP_EVENT 0x00000400 @@ -390,7 +385,7 @@ extern ngx_event_actions_t ngx_event_a typedef struct { ngx_uint_t connections; - ngx_int_t use; + ngx_uint_t use; ngx_flag_t multi_accept; ngx_flag_t accept_mutex; diff --git a/src/http/modules/ngx_http_charset_filter.c b/src/http/modules/ngx_http_charset_filter.c --- a/src/http/modules/ngx_http_charset_filter.c +++ b/src/http/modules/ngx_http_charset_filter.c @@ -128,7 +128,7 @@ static ngx_http_output_header_filter_pt static ngx_http_output_body_filter_pt ngx_http_next_body_filter; -static int ngx_http_charset_header_filter(ngx_http_request_t *r) +static ngx_int_t ngx_http_charset_header_filter(ngx_http_request_t *r) { ngx_http_charset_t *charsets; ngx_http_charset_ctx_t *ctx; @@ -190,7 +190,8 @@ static int ngx_http_charset_header_filte } -static int ngx_http_charset_body_filter(ngx_http_request_t *r, ngx_chain_t *in) +static ngx_int_t ngx_http_charset_body_filter(ngx_http_request_t *r, + ngx_chain_t *in) { char *table; ngx_chain_t *cl; diff --git a/src/http/modules/ngx_http_chunked_filter.c b/src/http/modules/ngx_http_chunked_filter.c --- a/src/http/modules/ngx_http_chunked_filter.c +++ b/src/http/modules/ngx_http_chunked_filter.c @@ -4,7 +4,7 @@ #include -static int ngx_http_chunked_filter_init(ngx_cycle_t *cycle); +static ngx_int_t ngx_http_chunked_filter_init(ngx_cycle_t *cycle); static ngx_http_module_t ngx_http_chunked_filter_module_ctx = { @@ -35,7 +35,7 @@ static ngx_http_output_header_filter_pt static ngx_http_output_body_filter_pt ngx_http_next_body_filter; -static int ngx_http_chunked_header_filter(ngx_http_request_t *r) +static ngx_int_t ngx_http_chunked_header_filter(ngx_http_request_t *r) { if (r->headers_out.status == NGX_HTTP_NOT_MODIFIED) { return ngx_http_next_header_filter(r); @@ -54,7 +54,8 @@ static int ngx_http_chunked_header_filte } -static int ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in) +static ngx_int_t ngx_http_chunked_body_filter(ngx_http_request_t *r, + ngx_chain_t *in) { u_char *chunk; size_t size, len; @@ -138,7 +139,7 @@ static int ngx_http_chunked_body_filter( } -static int ngx_http_chunked_filter_init(ngx_cycle_t *cycle) +static ngx_int_t ngx_http_chunked_filter_init(ngx_cycle_t *cycle) { ngx_http_next_header_filter = ngx_http_top_header_filter; ngx_http_top_header_filter = ngx_http_chunked_header_filter; diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c --- a/src/http/modules/ngx_http_gzip_filter.c +++ b/src/http/modules/ngx_http_gzip_filter.c @@ -64,8 +64,8 @@ typedef struct { } ngx_http_gzip_ctx_t; -static int ngx_http_gzip_proxied(ngx_http_request_t *r, - ngx_http_gzip_conf_t *conf); +static ngx_int_t ngx_http_gzip_proxied(ngx_http_request_t *r, + ngx_http_gzip_conf_t *conf); static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size); static void ngx_http_gzip_filter_free(void *opaque, void *address); @@ -74,8 +74,8 @@ ngx_inline static int ngx_http_gzip_erro static u_char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, u_char *buf, uintptr_t data); -static int ngx_http_gzip_pre_conf(ngx_conf_t *cf); -static int ngx_http_gzip_filter_init(ngx_cycle_t *cycle); +static ngx_int_t ngx_http_gzip_pre_conf(ngx_conf_t *cf); +static ngx_int_t ngx_http_gzip_filter_init(ngx_cycle_t *cycle); static void *ngx_http_gzip_create_conf(ngx_conf_t *cf); static char *ngx_http_gzip_merge_conf(ngx_conf_t *cf, void *parent, void *child); @@ -238,7 +238,7 @@ static ngx_http_output_header_filter_pt static ngx_http_output_body_filter_pt ngx_http_next_body_filter; -static int ngx_http_gzip_header_filter(ngx_http_request_t *r) +static ngx_int_t ngx_http_gzip_header_filter(ngx_http_request_t *r) { ngx_http_gzip_ctx_t *ctx; ngx_http_gzip_conf_t *conf; @@ -288,10 +288,7 @@ static int ngx_http_gzip_header_filter(n * hangs up or crashes */ - if (r->headers_in.user_agent - && r->unparsed_uri.len > 200 - && ngx_strstr(r->headers_in.user_agent->value.data, "MSIE 4")) - { + if (r->headers_in.msie4 && r->unparsed_uri.len > 200) { return ngx_http_next_header_filter(r); } @@ -323,8 +320,8 @@ static int ngx_http_gzip_header_filter(n } -static int ngx_http_gzip_proxied(ngx_http_request_t *r, - ngx_http_gzip_conf_t *conf) +static ngx_int_t ngx_http_gzip_proxied(ngx_http_request_t *r, + ngx_http_gzip_conf_t *conf) { time_t date, expires; @@ -403,7 +400,8 @@ static int ngx_http_gzip_proxied(ngx_htt } -static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in) +static ngx_int_t ngx_http_gzip_body_filter(ngx_http_request_t *r, + ngx_chain_t *in) { int rc, wbits, memlevel, last; struct gztrailer *trailer; @@ -819,7 +817,8 @@ static u_char *ngx_http_gzip_log_ratio(n } return buf + ngx_snprintf((char *) buf, NGX_INT32_LEN + 4, - "%d.%02d", zint, zfrac); + "%" NGX_UINT_T_FMT ".%02" NGX_UINT_T_FMT, + zint, zfrac); } @@ -838,7 +837,7 @@ ngx_inline static int ngx_http_gzip_erro } -static int ngx_http_gzip_pre_conf(ngx_conf_t *cf) +static ngx_int_t ngx_http_gzip_pre_conf(ngx_conf_t *cf) { ngx_http_log_op_name_t *op; @@ -859,7 +858,7 @@ static int ngx_http_gzip_pre_conf(ngx_co } -static int ngx_http_gzip_filter_init(ngx_cycle_t *cycle) +static ngx_int_t ngx_http_gzip_filter_init(ngx_cycle_t *cycle) { ngx_http_next_header_filter = ngx_http_top_header_filter; ngx_http_top_header_filter = ngx_http_gzip_header_filter; @@ -894,9 +893,9 @@ static void *ngx_http_gzip_create_conf(n conf->http_version = NGX_CONF_UNSET_UINT; conf->level = NGX_CONF_UNSET; - conf->wbits = NGX_CONF_UNSET_UINT; - conf->memlevel = NGX_CONF_UNSET_UINT; - conf->min_length = NGX_CONF_UNSET_UINT; + conf->wbits = (size_t) NGX_CONF_UNSET; + conf->memlevel = (size_t) NGX_CONF_UNSET; + conf->min_length = NGX_CONF_UNSET; return conf; } diff --git a/src/http/modules/ngx_http_headers_filter.c b/src/http/modules/ngx_http_headers_filter.c --- a/src/http/modules/ngx_http_headers_filter.c +++ b/src/http/modules/ngx_http_headers_filter.c @@ -14,7 +14,7 @@ typedef struct { #define NGX_HTTP_EXPIRES_EPOCH -2147483645 -static int ngx_http_headers_filter_init(ngx_cycle_t *cycle); +static ngx_int_t ngx_http_headers_filter_init(ngx_cycle_t *cycle); static void *ngx_http_headers_create_conf(ngx_conf_t *cf); static char *ngx_http_headers_merge_conf(ngx_conf_t *cf, void *parent, void *child); @@ -61,7 +61,7 @@ ngx_module_t ngx_http_headers_filter_mo static ngx_http_output_header_filter_pt ngx_http_next_header_filter; -static int ngx_http_headers_filter(ngx_http_request_t *r) +static ngx_int_t ngx_http_headers_filter(ngx_http_request_t *r) { size_t len; ngx_table_elt_t *expires, *cc; @@ -145,7 +145,7 @@ static int ngx_http_headers_filter(ngx_h } -static int ngx_http_headers_filter_init(ngx_cycle_t *cycle) +static ngx_int_t ngx_http_headers_filter_init(ngx_cycle_t *cycle) { ngx_http_next_header_filter = ngx_http_top_header_filter; ngx_http_top_header_filter = ngx_http_headers_filter; diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c --- a/src/http/modules/ngx_http_index_handler.c +++ b/src/http/modules/ngx_http_index_handler.c @@ -29,7 +29,7 @@ static ngx_int_t ngx_http_index_test_dir static ngx_int_t ngx_http_index_error(ngx_http_request_t *r, ngx_http_index_ctx_t *ctx, ngx_err_t err); -static int ngx_http_index_init(ngx_cycle_t *cycle); +static ngx_int_t ngx_http_index_init(ngx_cycle_t *cycle); static void *ngx_http_index_create_loc_conf(ngx_conf_t *cf); static char *ngx_http_index_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child); @@ -95,7 +95,7 @@ ngx_module_t ngx_http_index_module = { * that path contains the usual file in place of the directory. */ -int ngx_http_index_handler(ngx_http_request_t *r) +ngx_int_t ngx_http_index_handler(ngx_http_request_t *r) { u_char *name; ngx_fd_t fd; @@ -361,7 +361,7 @@ static ngx_int_t ngx_http_index_error(ng } -static int ngx_http_index_init(ngx_cycle_t *cycle) +static ngx_int_t ngx_http_index_init(ngx_cycle_t *cycle) { ngx_http_handler_pt *h; ngx_http_conf_ctx_t *ctx; diff --git a/src/http/modules/ngx_http_not_modified_filter.c b/src/http/modules/ngx_http_not_modified_filter.c --- a/src/http/modules/ngx_http_not_modified_filter.c +++ b/src/http/modules/ngx_http_not_modified_filter.c @@ -5,7 +5,7 @@ -static int ngx_http_not_modified_filter_init(ngx_cycle_t *cycle); +static ngx_int_t ngx_http_not_modified_filter_init(ngx_cycle_t *cycle); static ngx_http_module_t ngx_http_not_modified_filter_module_ctx = { @@ -35,7 +35,7 @@ ngx_module_t ngx_http_not_modified_filt static ngx_http_output_header_filter_pt ngx_http_next_header_filter; -static int ngx_http_not_modified_header_filter(ngx_http_request_t *r) +static ngx_int_t ngx_http_not_modified_header_filter(ngx_http_request_t *r) { time_t ims; @@ -71,7 +71,7 @@ static int ngx_http_not_modified_header_ } -static int ngx_http_not_modified_filter_init(ngx_cycle_t *cycle) +static ngx_int_t ngx_http_not_modified_filter_init(ngx_cycle_t *cycle) { ngx_http_next_header_filter = ngx_http_top_header_filter; ngx_http_top_header_filter = ngx_http_not_modified_header_filter; diff --git a/src/http/modules/ngx_http_range_filter.c b/src/http/modules/ngx_http_range_filter.c --- a/src/http/modules/ngx_http_range_filter.c +++ b/src/http/modules/ngx_http_range_filter.c @@ -339,7 +339,7 @@ static ngx_int_t ngx_http_range_header_f if (r->headers_out.charset.len) { ctx->boundary_header.len = ngx_snprintf((char *) ctx->boundary_header.data, len, - CRLF "--%010u" CRLF + CRLF "--%010" NGX_UINT_T_FMT CRLF "Content-Type: %s; charset=%s" CRLF "Content-Range: bytes ", boundary, @@ -351,7 +351,7 @@ static ngx_int_t ngx_http_range_header_f } else { ctx->boundary_header.len = ngx_snprintf((char *) ctx->boundary_header.data, len, - CRLF "--%010u" CRLF + CRLF "--%010" NGX_UINT_T_FMT CRLF "Content-Type: %s" CRLF "Content-Range: bytes ", boundary, @@ -368,7 +368,8 @@ static ngx_int_t ngx_http_range_header_f ngx_snprintf((char *) r->headers_out.content_type->value.data, 31 + 10 + 1, - "multipart/byteranges; boundary=%010u", + "multipart/byteranges; boundary=%010" + NGX_UINT_T_FMT, boundary); /* the size of the last boundary CRLF "--0123456789--" CRLF */ diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -5,7 +5,7 @@ #include -static int ngx_http_proxy_handler(ngx_http_request_t *r); +static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r); static u_char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, u_char *buf, uintptr_t data); @@ -14,7 +14,7 @@ static u_char *ngx_http_proxy_log_cache_ static u_char *ngx_http_proxy_log_reason(ngx_http_request_t *r, u_char *buf, uintptr_t data); -static int ngx_http_proxy_pre_conf(ngx_conf_t *cf); +static ngx_int_t ngx_http_proxy_pre_conf(ngx_conf_t *cf); static void *ngx_http_proxy_create_loc_conf(ngx_conf_t *cf); static char *ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child); @@ -307,7 +307,7 @@ static ngx_str_t cache_reasons[] = { }; -static int ngx_http_proxy_handler(ngx_http_request_t *r) +static ngx_int_t ngx_http_proxy_handler(ngx_http_request_t *r) { ngx_http_proxy_ctx_t *p; @@ -732,7 +732,8 @@ static u_char *ngx_http_proxy_log_proxy_ *buf++ = '-'; } else { - buf += ngx_snprintf((char *) buf, 4, "%d", p->state->status); + buf += ngx_snprintf((char *) buf, 4, "%" NGX_UINT_T_FMT, + p->state->status); } *buf++ = '/'; @@ -796,7 +797,7 @@ static u_char *ngx_http_proxy_log_reason } -static int ngx_http_proxy_pre_conf(ngx_conf_t *cf) +static ngx_int_t ngx_http_proxy_pre_conf(ngx_conf_t *cf) { ngx_http_log_op_name_t *op; diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c --- a/src/http/ngx_http.c +++ b/src/http/ngx_http.c @@ -14,8 +14,8 @@ ngx_uint_t ngx_http_total_requests; uint64_t ngx_http_total_sent; -int (*ngx_http_top_header_filter) (ngx_http_request_t *r); -int (*ngx_http_top_body_filter) (ngx_http_request_t *r, ngx_chain_t *ch); +ngx_int_t (*ngx_http_top_header_filter) (ngx_http_request_t *r); +ngx_int_t (*ngx_http_top_body_filter) (ngx_http_request_t *r, ngx_chain_t *ch); static ngx_command_t ngx_http_commands[] = { diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h --- a/src/http/ngx_http.h +++ b/src/http/ngx_http.h @@ -59,26 +59,26 @@ int ngx_http_init(ngx_pool_t *pool, ngx_ void ngx_http_init_connection(ngx_connection_t *c); -int ngx_http_parse_request_line(ngx_http_request_t *r); -int ngx_http_parse_complex_uri(ngx_http_request_t *r); -int ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b); +ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r); +ngx_int_t ngx_http_parse_complex_uri(ngx_http_request_t *r); +ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b); -int ngx_http_find_server_conf(ngx_http_request_t *r); +ngx_int_t ngx_http_find_server_conf(ngx_http_request_t *r); void ngx_http_handler(ngx_http_request_t *r); void ngx_http_finalize_request(ngx_http_request_t *r, int error); void ngx_http_writer(ngx_event_t *wev); void ngx_http_empty_handler(ngx_event_t *wev); -int ngx_http_send_last(ngx_http_request_t *r); +ngx_int_t ngx_http_send_last(ngx_http_request_t *r); void ngx_http_close_request(ngx_http_request_t *r, int error); void ngx_http_close_connection(ngx_connection_t *c); ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r); -int ngx_http_send_header(ngx_http_request_t *r); -int ngx_http_special_response_handler(ngx_http_request_t *r, int error); +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); time_t ngx_http_parse_time(u_char *value, size_t len); @@ -88,8 +88,7 @@ ngx_table_elt_t *ngx_http_add_header(voi -int ngx_http_discard_body(ngx_http_request_t *r); - +ngx_int_t ngx_http_discard_body(ngx_http_request_t *r); extern ngx_module_t ngx_http_module; @@ -99,9 +98,12 @@ extern ngx_uint_t ngx_http_total_reques extern uint64_t ngx_http_total_sent; +extern ngx_http_output_header_filter_pt ngx_http_top_header_filter; +extern ngx_http_output_body_filter_pt ngx_http_top_body_filter; + /* STUB */ -int ngx_http_log_handler(ngx_http_request_t *r); +ngx_int_t ngx_http_log_handler(ngx_http_request_t *r); /**/ diff --git a/src/http/ngx_http_config.h b/src/http/ngx_http_config.h --- a/src/http/ngx_http_config.h +++ b/src/http/ngx_http_config.h @@ -14,22 +14,16 @@ typedef struct { typedef struct { - int (*output_header_filter) (ngx_http_request_t *r); - int (*output_body_filter) (ngx_http_request_t *r, ngx_chain_t *ch); -} ngx_http_conf_filter_t; + ngx_int_t (*pre_conf)(ngx_conf_t *cf); - -typedef struct { - int (*pre_conf)(ngx_conf_t *cf); + void *(*create_main_conf)(ngx_conf_t *cf); + char *(*init_main_conf)(ngx_conf_t *cf, void *conf); - void *(*create_main_conf)(ngx_conf_t *cf); - char *(*init_main_conf)(ngx_conf_t *cf, void *conf); + void *(*create_srv_conf)(ngx_conf_t *cf); + char *(*merge_srv_conf)(ngx_conf_t *cf, void *prev, void *conf); - void *(*create_srv_conf)(ngx_conf_t *cf); - char *(*merge_srv_conf)(ngx_conf_t *cf, void *prev, void *conf); - - void *(*create_loc_conf)(ngx_conf_t *cf); - char *(*merge_loc_conf)(ngx_conf_t *cf, void *prev, void *conf); + void *(*create_loc_conf)(ngx_conf_t *cf); + char *(*merge_loc_conf)(ngx_conf_t *cf, void *prev, void *conf); } ngx_http_module_t; @@ -53,7 +47,5 @@ typedef struct { ((ngx_http_conf_ctx_t *) cf->ctx)->main_conf[module.ctx_index] -extern int (*ngx_http_top_header_filter) (ngx_http_request_t *r); - #endif /* _NGX_HTTP_CONFIG_H_INCLUDED_ */ diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -18,7 +18,7 @@ static void *ngx_http_core_create_loc_co static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child); -static int ngx_http_core_init(ngx_cycle_t *cycle); +static ngx_int_t ngx_http_core_init(ngx_cycle_t *cycle); static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy); static int ngx_cmp_locations(const void *first, const void *second); static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, @@ -448,7 +448,7 @@ static void ngx_http_run_phases(ngx_http } -int ngx_http_find_location_config(ngx_http_request_t *r) +ngx_int_t ngx_http_find_location_config(ngx_http_request_t *r) { int rc; ngx_uint_t i; @@ -665,7 +665,7 @@ ngx_int_t ngx_http_set_content_type(ngx_ } -int ngx_http_send_header(ngx_http_request_t *r) +ngx_int_t ngx_http_send_header(ngx_http_request_t *r) { if (r->main) { return NGX_OK; @@ -743,8 +743,8 @@ ngx_int_t ngx_http_set_exten(ngx_http_re } -int ngx_http_internal_redirect(ngx_http_request_t *r, - ngx_str_t *uri, ngx_str_t *args) +ngx_int_t ngx_http_internal_redirect(ngx_http_request_t *r, + ngx_str_t *uri, ngx_str_t *args) { ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "internal redirect: \"%s\"", uri->data); @@ -808,7 +808,7 @@ int ngx_http_delay_handler(ngx_http_requ #endif -static int ngx_http_core_init(ngx_cycle_t *cycle) +static ngx_int_t ngx_http_core_init(ngx_cycle_t *cycle) { #if 0 ngx_http_handler_pt *h; diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h --- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -117,7 +117,7 @@ typedef struct { ngx_str_t name; /* location name */ void **loc_conf ; /* pointer to the modules' loc_conf */ - int (*handler) (ngx_http_request_t *r); + ngx_http_handler_pt handler; ngx_str_t root; /* root, alias */ @@ -163,27 +163,23 @@ extern int ngx_http_max_module; -int ngx_http_find_location_config(ngx_http_request_t *r); -int ngx_http_core_translate_handler(ngx_http_request_t *r); +ngx_int_t ngx_http_find_location_config(ngx_http_request_t *r); +ngx_int_t ngx_http_core_translate_handler(ngx_http_request_t *r); 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); -int ngx_http_internal_redirect(ngx_http_request_t *r, - ngx_str_t *uri, ngx_str_t *args); +ngx_int_t ngx_http_internal_redirect(ngx_http_request_t *r, + ngx_str_t *uri, ngx_str_t *args); -typedef int (*ngx_http_output_header_filter_pt)(ngx_http_request_t *r); -typedef int (*ngx_http_output_body_filter_pt) +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); -int ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *chain); -int ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *chain); - - -extern ngx_http_output_header_filter_pt ngx_http_top_header_filter; -extern ngx_http_output_body_filter_pt ngx_http_top_body_filter; +ngx_int_t ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *chain); +ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *chain); #endif /* _NGX_HTTP_CORE_H_INCLUDED_ */ diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c --- a/src/http/ngx_http_header_filter.c +++ b/src/http/ngx_http_header_filter.c @@ -5,8 +5,8 @@ #include -static int ngx_http_header_filter_init(ngx_cycle_t *cycle); -static int ngx_http_header_filter(ngx_http_request_t *r); +static ngx_int_t ngx_http_header_filter_init(ngx_cycle_t *cycle); +static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r); static ngx_http_module_t ngx_http_header_filter_module_ctx = { @@ -90,7 +90,7 @@ static ngx_str_t http_codes[] = { -static int ngx_http_header_filter(ngx_http_request_t *r) +static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r) { u_char *p; size_t len; @@ -359,7 +359,7 @@ static int ngx_http_header_filter(ngx_ht } -static int ngx_http_header_filter_init(ngx_cycle_t *cycle) +static ngx_int_t ngx_http_header_filter_init(ngx_cycle_t *cycle) { ngx_http_top_header_filter = ngx_http_header_filter; diff --git a/src/http/ngx_http_log_handler.c b/src/http/ngx_http_log_handler.c --- a/src/http/ngx_http_log_handler.c +++ b/src/http/ngx_http_log_handler.c @@ -35,7 +35,7 @@ static u_char *ngx_http_log_header_out(n static u_char *ngx_http_log_unknown_header_out(ngx_http_request_t *r, u_char *buf, uintptr_t data); -static int ngx_http_log_pre_conf(ngx_conf_t *cf); +static ngx_int_t ngx_http_log_pre_conf(ngx_conf_t *cf); static void *ngx_http_log_create_main_conf(ngx_conf_t *cf); static void *ngx_http_log_create_loc_conf(ngx_conf_t *cf); static char *ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, @@ -44,8 +44,8 @@ static char *ngx_http_log_set_log(ngx_co void *conf); static char *ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); -static int ngx_http_log_parse_format(ngx_conf_t *cf, ngx_array_t *ops, - ngx_str_t *line); +static ngx_int_t ngx_http_log_parse_format(ngx_conf_t *cf, ngx_array_t *ops, + ngx_str_t *line); static ngx_command_t ngx_http_log_commands[] = { @@ -116,7 +116,7 @@ ngx_http_log_op_name_t ngx_http_log_fmt_ }; -int ngx_http_log_handler(ngx_http_request_t *r) +ngx_int_t ngx_http_log_handler(ngx_http_request_t *r) { ngx_uint_t i, l; uintptr_t data; @@ -198,7 +198,8 @@ static u_char *ngx_http_log_addr(ngx_htt static u_char *ngx_http_log_connection(ngx_http_request_t *r, u_char *buf, uintptr_t data) { - return buf + ngx_snprintf((char *) buf, NGX_INT32_LEN + 1, "%u", + return buf + ngx_snprintf((char *) buf, NGX_INT_T_LEN + 1, + "%" NGX_UINT_T_FMT, r->connection->number); } @@ -239,7 +240,7 @@ static u_char *ngx_http_log_request(ngx_ static u_char *ngx_http_log_status(ngx_http_request_t *r, u_char *buf, uintptr_t data) { - return buf + ngx_snprintf((char *) buf, 4, "%d", + return buf + ngx_snprintf((char *) buf, 4, "%" NGX_UINT_T_FMT, r->err_status ? r->err_status : r->headers_out.status); } @@ -561,7 +562,7 @@ static u_char *ngx_http_log_unknown_head } -static int ngx_http_log_pre_conf(ngx_conf_t *cf) +static ngx_int_t ngx_http_log_pre_conf(ngx_conf_t *cf) { ngx_http_log_op_name_t *op; diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -9,13 +9,13 @@ static void ngx_http_init_request(ngx_ev static void ngx_http_process_request_line(ngx_event_t *rev); static void ngx_http_process_request_headers(ngx_event_t *rev); static ssize_t ngx_http_read_request_header(ngx_http_request_t *r); -static int ngx_http_process_request_header(ngx_http_request_t *r); +static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r); static void ngx_http_set_write_handler(ngx_http_request_t *r); static void ngx_http_block_read(ngx_event_t *ev); static void ngx_http_read_discarded_body_event(ngx_event_t *rev); -static int ngx_http_read_discarded_body(ngx_http_request_t *r); +static ngx_int_t ngx_http_read_discarded_body(ngx_http_request_t *r); static void ngx_http_set_keepalive(ngx_http_request_t *r); static void ngx_http_keepalive_handler(ngx_event_t *ev); @@ -847,6 +847,7 @@ static ssize_t ngx_http_read_request_hea static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r) { + u_char *ua; size_t len; ngx_uint_t i; ngx_http_server_name_t *name; @@ -935,6 +936,25 @@ static ngx_int_t ngx_http_process_reques } } + if (r->headers_in.user_agent) { + + /* + * check some widespread browsers while the headers are still + * in CPU cache + */ + + ua = ngx_strstr(r->headers_in.user_agent->value.data, "MSIE"); + if (ua + && ua + 8 < r->headers_in.user_agent->value.data + + r->headers_in.user_agent->value.len) + { + r->headers_in.msie = 1; + if (ua[4] == ' ' && ua[5] == '4' && ua[6] == '.') { + r->headers_in.msie4 = 1; + } + } + } + return NGX_OK; } @@ -1116,7 +1136,7 @@ static void ngx_http_block_read(ngx_even } -int ngx_http_discard_body(ngx_http_request_t *r) +ngx_int_t ngx_http_discard_body(ngx_http_request_t *r) { ssize_t size; ngx_event_t *rev; @@ -1182,7 +1202,7 @@ static void ngx_http_read_discarded_body } -static int ngx_http_read_discarded_body(ngx_http_request_t *r) +static ngx_int_t ngx_http_read_discarded_body(ngx_http_request_t *r) { ssize_t size, n; ngx_http_core_loc_conf_t *clcf; @@ -1523,7 +1543,7 @@ void ngx_http_empty_handler(ngx_event_t } -int ngx_http_send_last(ngx_http_request_t *r) +ngx_int_t ngx_http_send_last(ngx_http_request_t *r) { ngx_buf_t *b; ngx_chain_t out; diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h @@ -135,6 +135,9 @@ typedef struct { ssize_t content_length_n; size_t connection_type; ssize_t keep_alive_n; + + unsigned msie; + unsigned msie4; } ngx_http_headers_in_t; @@ -201,7 +204,7 @@ struct ngx_http_cleanup_s { }; -typedef int (*ngx_http_handler_pt)(ngx_http_request_t *r); +typedef ngx_int_t (*ngx_http_handler_pt)(ngx_http_request_t *r); struct ngx_http_request_s { ngx_connection_t *connection; diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c --- a/src/http/ngx_http_special_response.c +++ b/src/http/ngx_http_special_response.c @@ -177,10 +177,10 @@ static ngx_str_t error_pages[] = { }; -int 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, int error) { ngx_int_t rc; - ngx_uint_t err, i; + ngx_uint_t err, i, msie_padding; ngx_buf_t *b; ngx_chain_t *out, **ll, *cl; ngx_http_err_page_t *err_page; @@ -248,16 +248,20 @@ int ngx_http_special_response_handler(ng } } + msie_padding = 0; + if (error_pages[err].len) { r->headers_out.content_length_n = error_pages[err].len + sizeof(error_tail) - 1; if (clcf->msie_padding + && r->headers_in.msie && r->http_version >= NGX_HTTP_VERSION_10 && error >= NGX_HTTP_BAD_REQUEST && error != NGX_HTTP_REQUEST_URI_TOO_LARGE) { r->headers_out.content_length_n += sizeof(msie_stub) - 1; + msie_padding = 1; } if (!(r->headers_out.content_type = @@ -314,11 +318,7 @@ int ngx_http_special_response_handler(ng ngx_alloc_link_and_set_buf(cl, b, r->pool, NGX_ERROR); ngx_chain_add_link(out, ll, cl); - if (clcf->msie_padding - && r->http_version >= NGX_HTTP_VERSION_10 - && error >= NGX_HTTP_BAD_REQUEST - && error != NGX_HTTP_REQUEST_URI_TOO_LARGE) - { + if (msie_padding) { if (!(b = ngx_calloc_buf(r->pool))) { return NGX_ERROR; } diff --git a/src/http/ngx_http_write_filter.c b/src/http/ngx_http_write_filter.c --- a/src/http/ngx_http_write_filter.c +++ b/src/http/ngx_http_write_filter.c @@ -18,7 +18,7 @@ typedef struct { static void *ngx_http_write_filter_create_conf(ngx_conf_t *cf); static char *ngx_http_write_filter_merge_conf(ngx_conf_t *cf, void *parent, void *child); -static int ngx_http_write_filter_init(ngx_cycle_t *cycle); +static ngx_int_t ngx_http_write_filter_init(ngx_cycle_t *cycle); static ngx_command_t ngx_http_write_filter_commands[] = { @@ -66,7 +66,7 @@ ngx_module_t ngx_http_write_filter_modu }; -int ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) +ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) { int last; off_t size, flush; @@ -196,7 +196,7 @@ static char *ngx_http_write_filter_merge } -static int ngx_http_write_filter_init(ngx_cycle_t *cycle) +static ngx_int_t ngx_http_write_filter_init(ngx_cycle_t *cycle) { ngx_http_top_body_filter = ngx_http_write_filter;