Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-06-06 23:49:18 +0400
committerIgor Sysoev <igor@sysoev.ru>2004-06-06 23:49:18 +0400
commit0ab91b901299ac41e3867ebec7e04e5082a4c8b4 (patch)
treeb89e863c141bc482c85c351f84d9dca1d3570789 /src
parent6e1bbd78967660b49e3a120bbeec6382ed193d5f (diff)
nginx-0.0.3-2004-06-06-23:49:18 import
Diffstat (limited to 'src')
-rw-r--r--src/core/ngx_config.h10
-rw-r--r--src/core/ngx_connection.c2
-rw-r--r--src/core/ngx_connection.h1
-rw-r--r--src/core/ngx_core.h1
-rw-r--r--src/core/ngx_palloc.c (renamed from src/core/ngx_alloc.c)60
-rw-r--r--src/core/ngx_palloc.h (renamed from src/core/ngx_alloc.h)13
-rw-r--r--src/event/modules/ngx_rtsig_module.c4
-rw-r--r--src/event/ngx_event.c2
-rw-r--r--src/event/ngx_event.h4
-rw-r--r--src/event/ngx_event_accept.c26
-rw-r--r--src/http/modules/ngx_http_charset_filter.c2
-rw-r--r--src/http/modules/ngx_http_gzip_filter.c17
-rw-r--r--src/http/modules/ngx_http_range_filter.c2
-rw-r--r--src/http/modules/ngx_http_static_handler.c2
-rw-r--r--src/http/ngx_http.h1
-rw-r--r--src/http/ngx_http_copy_filter.c4
-rw-r--r--src/http/ngx_http_core_module.c11
-rw-r--r--src/http/ngx_http_core_module.h14
-rw-r--r--src/http/ngx_http_filter.h24
-rw-r--r--src/http/ngx_http_request.c29
-rw-r--r--src/http/ngx_http_request.h6
-rw-r--r--src/os/unix/ngx_alloc.c75
-rw-r--r--src/os/unix/ngx_alloc.h36
-rw-r--r--src/os/unix/ngx_freebsd_rfork_thread.c3
-rw-r--r--src/os/unix/ngx_posix_init.c2
-rw-r--r--src/os/unix/ngx_socket.c4
-rw-r--r--src/os/unix/ngx_time.h2
-rw-r--r--src/os/win32/ngx_alloc.c36
-rw-r--r--src/os/win32/ngx_alloc.h18
-rw-r--r--src/os/win32/ngx_win32_init.c4
30 files changed, 299 insertions, 116 deletions
diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h
index 448e63ab6..02983151a 100644
--- a/src/core/ngx_config.h
+++ b/src/core/ngx_config.h
@@ -40,19 +40,9 @@
/* STUB: autoconf */
typedef int ngx_int_t;
typedef u_int ngx_uint_t;
-
-
typedef int ngx_flag_t;
-#ifndef NGX_SERVER_ROOT
-#define NGX_SERVER_ROOT "./"
-#if 0
-#define NGX_SERVER_ROOT "/usr/local/nginx/"
-#endif
-#endif
-
-
#if !(WIN32)
#define ngx_signal_helper(n) SIG##n
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
index 6382ec10c..d5de07675 100644
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -228,7 +228,7 @@ void ngx_close_listening_sockets(ngx_cycle_t *cycle)
fd /= 4;
#endif
- if (ngx_event_flags & NGX_USE_SIGIO_EVENT) {
+ if (ngx_event_flags & NGX_USE_RTSIG_EVENT) {
if (cycle->connections[fd].read->active) {
ngx_del_conn(&cycle->connections[fd], NGX_CLOSE_EVENT);
}
diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h
index ecd3c8bc4..8dbc4e49f 100644
--- a/src/core/ngx_connection.h
+++ b/src/core/ngx_connection.h
@@ -103,6 +103,7 @@ struct ngx_connection_s {
unsigned pipeline:1;
unsigned unexpected_eof:1;
+ unsigned timedout:1;
signed tcp_nopush:2;
#if (HAVE_IOCP)
unsigned accept_context_updated:1;
diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h
index ccb357bfe..1e194e719 100644
--- a/src/core/ngx_core.h
+++ b/src/core/ngx_core.h
@@ -26,6 +26,7 @@ typedef struct ngx_connection_s ngx_connection_t;
#include <ngx_parse.h>
#include <ngx_log.h>
#include <ngx_alloc.h>
+#include <ngx_palloc.h>
#include <ngx_buf.h>
#include <ngx_array.h>
#include <ngx_table.h>
diff --git a/src/core/ngx_alloc.c b/src/core/ngx_palloc.c
index de583fc09..65e2eed66 100644
--- a/src/core/ngx_alloc.c
+++ b/src/core/ngx_palloc.c
@@ -3,35 +3,6 @@
#include <ngx_core.h>
-void *ngx_alloc(size_t size, ngx_log_t *log)
-{
- void *p;
-
- if (!(p = malloc(size))) {
- ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
- "malloc() " SIZE_T_FMT " bytes failed", size);
- }
-
- ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0,
- "malloc: " PTR_FMT ":" SIZE_T_FMT, p, size);
-
- return p;
-}
-
-
-void *ngx_calloc(size_t size, ngx_log_t *log)
-{
- void *p;
-
- p = ngx_alloc(size, log);
- if (p) {
- ngx_memzero(p, size);
- }
-
- return p;
-}
-
-
ngx_pool_t *ngx_create_pool(size_t size, ngx_log_t *log)
{
ngx_pool_t *p;
@@ -99,7 +70,7 @@ void *ngx_palloc(ngx_pool_t *pool, size_t size)
ngx_pool_t *p, *n;
ngx_pool_large_t *large, *last;
- if (size <= NGX_MAX_ALLOC_FROM_POOL) {
+ if (size <= (size_t) NGX_MAX_ALLOC_FROM_POOL) {
for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
m = ngx_align(p->last);
@@ -155,7 +126,7 @@ void *ngx_palloc(ngx_pool_t *pool, size_t size)
large->next = NULL;
}
- if (!(p = ngx_alloc(size, pool->log))) {
+ if (!(p = ngx_memalign(ngx_pagesize, size, pool->log))) {
return NULL;
}
@@ -198,3 +169,30 @@ void *ngx_pcalloc(ngx_pool_t *pool, size_t size)
return p;
}
+
+#if 0
+
+static void *ngx_get_cached_block(size_t size)
+{
+ void *p;
+ ngx_cached_block_slot_t *slot;
+
+ if (ngx_cycle->cache == NULL) {
+ return NULL;
+ }
+
+ slot = &ngx_cycle->cache[(size + ngx_pagesize - 1) / ngx_pagesize];
+
+ slot->tries++;
+
+ if (slot->number) {
+ p = slot->block;
+ slot->block = slot->block->next;
+ slot->number--;
+ return p;
+ }
+
+ return NULL;
+}
+
+#endif
diff --git a/src/core/ngx_alloc.h b/src/core/ngx_palloc.h
index e64f84f4a..7774d356c 100644
--- a/src/core/ngx_alloc.h
+++ b/src/core/ngx_palloc.h
@@ -1,5 +1,5 @@
-#ifndef _NGX_ALLOC_H_INCLUDED_
-#define _NGX_ALLOC_H_INCLUDED_
+#ifndef _NGX_PALLOC_H_INCLUDED_
+#define _NGX_PALLOC_H_INCLUDED_
#include <ngx_config.h>
@@ -7,11 +7,11 @@
/*
- * NGX_MAX_ALLOC_FROM_POOL should be (NGX_PAGE_SIZE - 1), i.e. 4095 on x86.
+ * NGX_MAX_ALLOC_FROM_POOL should be (ngx_page_size - 1), i.e. 4095 on x86.
* On FreeBSD 5.x it allows to use zero copy send.
* On Windows NT it decreases a number of locked pages in a kernel.
*/
-#define NGX_MAX_ALLOC_FROM_POOL 4095
+#define NGX_MAX_ALLOC_FROM_POOL (ngx_pagesize - 1)
#define NGX_DEFAULT_POOL_SIZE (16 * 1024)
@@ -48,7 +48,4 @@ void *ngx_pcalloc(ngx_pool_t *pool, size_t size);
void ngx_pfree(ngx_pool_t *pool, void *p);
-#define ngx_free free
-
-
-#endif /* _NGX_ALLOC_H_INCLUDED_ */
+#endif /* _NGX_PALLOC_H_INCLUDED_ */
diff --git a/src/event/modules/ngx_rtsig_module.c b/src/event/modules/ngx_rtsig_module.c
index 120624594..ec7dd17bc 100644
--- a/src/event/modules/ngx_rtsig_module.c
+++ b/src/event/modules/ngx_rtsig_module.c
@@ -114,7 +114,7 @@ static int ngx_rtsig_init(ngx_cycle_t *cycle)
ngx_event_actions = ngx_rtsig_module_ctx.actions;
- ngx_event_flags = NGX_USE_SIGIO_EVENT
+ ngx_event_flags = NGX_USE_RTSIG_EVENT
|NGX_HAVE_GREEDY_EVENT
|NGX_HAVE_INSTANCE_EVENT;
@@ -423,7 +423,7 @@ static int ngx_rtsig_process_overflow(ngx_cycle_t *cycle)
{
if (ngx_poll_module_ctx.actions.process(cycle) == NGX_OK) {
ngx_event_actions = ngx_rtsig_module_ctx.actions;
- ngx_event_flags = NGX_USE_SIGIO_EVENT;
+ ngx_event_flags = NGX_USE_RTSIG_EVENT;
}
return NGX_OK;
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index e9ec48ece..b8bed8950 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -375,7 +375,7 @@ static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle)
continue;
}
- if (ngx_event_flags & NGX_USE_SIGIO_EVENT) {
+ if (ngx_event_flags & NGX_USE_RTSIG_EVENT) {
if (ngx_add_conn(c) == NGX_ERROR) {
return NGX_ERROR;
}
diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h
index e85f531b7..1b9dfb290 100644
--- a/src/event/ngx_event.h
+++ b/src/event/ngx_event.h
@@ -101,6 +101,8 @@ struct ngx_event_s {
unsigned short deferred_accept:1;
+ unsigned short overflow:1;
+
/* TODO: aio_eof and kq_eof can be the single pending_eof */
/* the pending eof in aio chain operation */
unsigned short aio_eof:1;
@@ -244,7 +246,7 @@ extern ngx_event_actions_t ngx_event_actions;
/*
* No need to add or delete the event filters - rt signals.
*/
-#define NGX_USE_SIGIO_EVENT 0x00000100
+#define NGX_USE_RTSIG_EVENT 0x00000100
/*
* The alternative event method after the rt signals queue overflow.
diff --git a/src/event/ngx_event_accept.c b/src/event/ngx_event_accept.c
index 5a3a451e7..9b53edbb5 100644
--- a/src/event/ngx_event_accept.c
+++ b/src/event/ngx_event_accept.c
@@ -30,7 +30,7 @@ void ngx_event_accept(ngx_event_t *ev)
ecf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_event_core_module);
- if (ngx_event_flags & (NGX_USE_EDGE_EVENT|NGX_USE_SIGIO_EVENT)) {
+ if (ngx_event_flags & (NGX_USE_EDGE_EVENT|NGX_USE_RTSIG_EVENT)) {
ev->available = 1;
} else if (!(ngx_event_flags & NGX_HAVE_KQUEUE_EVENT)) {
@@ -52,9 +52,9 @@ void ngx_event_accept(ngx_event_t *ev)
if (pool == NULL) {
/*
- * Create the pool before accept() to avoid copy the sockaddr.
- * Although accept() can fail it's an uncommon case
- * and besides the pool can be got from the free pool list
+ * Create the pool before accept() to avoid the copying of
+ * the sockaddr. Although accept() can fail it is uncommon
+ * case and besides the pool can be got from the free pool list
*/
if (!(pool = ngx_create_pool(ls->listening->pool_size, ev->log))) {
@@ -80,7 +80,7 @@ void ngx_event_accept(ngx_event_t *ev)
return;
}
- /* -1 disable logging the connection number */
+ /* -1 disables the connection number logging */
ctx->flag = -1;
ctx->name = ls->listening->addr_text.data;
@@ -95,7 +95,7 @@ void ngx_event_accept(ngx_event_t *ev)
if (err == NGX_EAGAIN) {
if (!(ngx_event_flags
- & (NGX_USE_EDGE_EVENT|NGX_USE_SIGIO_EVENT)))
+ & (NGX_USE_EDGE_EVENT|NGX_USE_RTSIG_EVENT)))
{
ngx_log_error(NGX_LOG_NOTICE, log, err,
"EAGAIN after %d accepted connection(s)",
@@ -167,7 +167,7 @@ void ngx_event_accept(ngx_event_t *ev)
}
} else {
- if (!(ngx_event_flags & NGX_USE_AIO_EVENT)) {
+ if (!(ngx_event_flags & (NGX_USE_AIO_EVENT|NGX_USE_RTSIG_EVENT))) {
if (ngx_nonblocking(s) == -1) {
ngx_log_error(NGX_LOG_ALERT, log, ngx_socket_errno,
ngx_nonblocking_n " failed");
@@ -246,9 +246,9 @@ void ngx_event_accept(ngx_event_t *ev)
wev->ready = 1;
if (ngx_event_flags
- & (NGX_USE_AIO_EVENT|NGX_USE_EDGE_EVENT|NGX_USE_SIGIO_EVENT))
+ & (NGX_USE_AIO_EVENT|NGX_USE_EDGE_EVENT|NGX_USE_RTSIG_EVENT))
{
- /* aio, iocp, sigio, epoll */
+ /* epoll, rtsig, aio, iocp */
rev->ready = 1;
}
@@ -366,12 +366,12 @@ ngx_int_t ngx_enable_accept_events(ngx_cycle_t *cycle)
for (i = 0; i < cycle->listening.nelts; i++) {
/*
- * we do not need to handle the Winsock sockets here (divde a socket
+ * we do not need to handle the Winsock sockets here (divide a socket
* number by 4) because this function would never called
* in the Winsock environment
*/
- if (ngx_event_flags & NGX_USE_SIGIO_EVENT) {
+ if (ngx_event_flags & NGX_USE_RTSIG_EVENT) {
if (ngx_add_conn(&cycle->connections[s[i].fd]) == NGX_ERROR) {
return NGX_ERROR;
}
@@ -398,12 +398,12 @@ ngx_int_t ngx_disable_accept_events(ngx_cycle_t *cycle)
for (i = 0; i < cycle->listening.nelts; i++) {
/*
- * we do not need to handle the Winsock sockets here (divde a socket
+ * we do not need to handle the Winsock sockets here (divide a socket
* number by 4) because this function would never called
* in the Winsock environment
*/
- if (ngx_event_flags & NGX_USE_SIGIO_EVENT) {
+ if (ngx_event_flags & NGX_USE_RTSIG_EVENT) {
if (!cycle->connections[s[i].fd].read->active) {
continue;
}
diff --git a/src/http/modules/ngx_http_charset_filter.c b/src/http/modules/ngx_http_charset_filter.c
index 279001baf..b79a4606c 100644
--- a/src/http/modules/ngx_http_charset_filter.c
+++ b/src/http/modules/ngx_http_charset_filter.c
@@ -184,7 +184,7 @@ static int ngx_http_charset_header_filter(ngx_http_request_t *r)
ngx_http_create_ctx(r, ctx, ngx_http_charset_filter_module,
sizeof(ngx_http_charset_ctx_t), NGX_ERROR);
- r->filter |= NGX_HTTP_FILTER_NEED_IN_MEMORY;
+ r->filter_need_in_memory = 1;
return ngx_http_next_header_filter(r);
}
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c
index eb9497517..cc7ba9c28 100644
--- a/src/http/modules/ngx_http_gzip_filter.c
+++ b/src/http/modules/ngx_http_gzip_filter.c
@@ -317,7 +317,7 @@ static int ngx_http_gzip_header_filter(ngx_http_request_t *r)
r->headers_out.content_length->key.len = 0;
r->headers_out.content_length = NULL;
}
- r->filter |= NGX_HTTP_FILTER_NEED_IN_MEMORY;
+ r->filter_need_in_memory = 1;
return ngx_http_next_header_filter(r);
}
@@ -438,12 +438,12 @@ static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
* We preallocate a memory for zlib in one buffer (200K-400K), this
* dicreases a number of malloc() and free() calls and also probably
* dicreases a number of syscalls (sbrk() or so).
- * Besides we free() this memory as soon as the gzipping will complete
+ * Besides we free this memory as soon as the gzipping will complete
* and do not wait while a whole response will be sent to a client.
*
* 8K is for zlib deflate_state (~6K).
*
- * TODO: 64-bit, round to PAGE_SIZE, autoconf of deflate_state size
+ * TODO: 64-bit, autoconf of deflate_state size
*/
ctx->allocated = 8192 + (1 << (wbits + 2)) + (1 << (memlevel + 9));
@@ -739,10 +739,12 @@ static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size)
alloc = items * size;
if (alloc % 512 != 0) {
- /* we allocate 8K for zlib deflate_state (~6K) */
- /* TODO: PAGE_SIZE */
+ /*
+ * allocate the zlib deflate_state, it takes about 6K on x86,
+ * we allocate 8K
+ */
- alloc = (alloc + 4095) & ~4095;
+ alloc = (alloc + ngx_pagesize - 1) & ~(ngx_pagesize - 1);
}
if (alloc <= ctx->allocated) {
@@ -900,8 +902,7 @@ static char *ngx_http_gzip_merge_conf(ngx_conf_t *cf,
ngx_conf_merge_value(conf->enable, prev->enable, 0);
- ngx_conf_merge_bufs_value(conf->bufs, prev->bufs, 4,
- /* STUB: PAGE_SIZE */ 4096);
+ ngx_conf_merge_bufs_value(conf->bufs, prev->bufs, 4, ngx_pagesize);
ngx_conf_merge_unsigned_value(conf->http_version, prev->http_version,
NGX_HTTP_VERSION_11);
diff --git a/src/http/modules/ngx_http_range_filter.c b/src/http/modules/ngx_http_range_filter.c
index 484bcb07b..65a5fd055 100644
--- a/src/http/modules/ngx_http_range_filter.c
+++ b/src/http/modules/ngx_http_range_filter.c
@@ -113,7 +113,7 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
if (r->http_version < NGX_HTTP_VERSION_10
|| r->headers_out.status != NGX_HTTP_OK
|| r->headers_out.content_length_n == -1
- || !(r->filter & NGX_HTTP_FILTER_ALLOW_RANGES))
+ || !r->filter_allow_ranges)
{
return ngx_http_next_header_filter(r);
}
diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c
index 532e8faab..9c11c7eb1 100644
--- a/src/http/modules/ngx_http_static_handler.c
+++ b/src/http/modules/ngx_http_static_handler.c
@@ -480,7 +480,7 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
- r->filter |= NGX_HTTP_FILTER_ALLOW_RANGES;
+ r->filter_allow_ranges = 1;
rc = ngx_http_send_header(r);
if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h
index bb718549b..87eabd1d2 100644
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -16,7 +16,6 @@ typedef struct ngx_http_cleanup_s ngx_http_cleanup_t;
#include <ngx_http_request.h>
#include <ngx_http_config.h>
#include <ngx_http_busy_lock.h>
-#include <ngx_http_filter.h>
#include <ngx_http_log_handler.h>
#include <ngx_http_core_module.h>
diff --git a/src/http/ngx_http_copy_filter.c b/src/http/ngx_http_copy_filter.c
index 96da0a517..6d901a467 100644
--- a/src/http/ngx_http_copy_filter.c
+++ b/src/http/ngx_http_copy_filter.c
@@ -75,8 +75,8 @@ ngx_int_t ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
sizeof(ngx_output_chain_ctx_t), NGX_ERROR);
ctx->sendfile = r->sendfile;
- ctx->need_in_memory = r->filter & NGX_HTTP_FILTER_NEED_IN_MEMORY;
- ctx->need_in_temp = r->filter & NGX_HTTP_FILTER_NEED_TEMP;
+ ctx->need_in_memory = r->filter_need_in_memory;
+ ctx->need_in_temp = r->filter_need_temporary;
ctx->pool = r->pool;
ctx->bufs = conf->bufs;
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index aeec7d21c..f68a60573 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -227,6 +227,13 @@ static ngx_command_t ngx_http_core_commands[] = {
offsetof(ngx_http_core_loc_conf_t, lingering_timeout),
NULL },
+ { ngx_string("reset_timedout_connection"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_core_loc_conf_t, reset_timedout_connection),
+ NULL },
+
{ ngx_string("msie_padding"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_flag_slot,
@@ -1238,7 +1245,7 @@ static void *ngx_http_core_create_loc_conf(ngx_conf_t *cf)
lcf->keepalive_timeout = NGX_CONF_UNSET_MSEC;
lcf->lingering_time = NGX_CONF_UNSET_MSEC;
lcf->lingering_timeout = NGX_CONF_UNSET_MSEC;
-
+ lcf->reset_timedout_connection = NGX_CONF_UNSET;
lcf->msie_padding = NGX_CONF_UNSET;
return lcf;
@@ -1326,6 +1333,8 @@ static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
ngx_conf_merge_msec_value(conf->lingering_timeout,
prev->lingering_timeout, 5000);
+ ngx_conf_merge_value(conf->reset_timedout_connection,
+ prev->reset_timedout_connection, 0);
ngx_conf_merge_value(conf->msie_padding, prev->msie_padding, 1);
if (conf->open_files == NULL) {
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index a8a6cf0ef..9224e9553 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -137,6 +137,7 @@ typedef struct {
ngx_flag_t sendfile; /* sendfile */
ngx_flag_t tcp_nopush; /* tcp_nopush */
+ ngx_flag_t reset_timedout_connection; /* reset_timedout_connection */
ngx_flag_t msie_padding; /* msie_padding */
ngx_array_t *error_pages; /* error_page */
@@ -172,4 +173,17 @@ int 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)
+ (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;
+
+
#endif /* _NGX_HTTP_CORE_H_INCLUDED_ */
diff --git a/src/http/ngx_http_filter.h b/src/http/ngx_http_filter.h
deleted file mode 100644
index d90947f05..000000000
--- a/src/http/ngx_http_filter.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _NGX_HTTP_FILTER_H_INCLUDED_
-#define _NGX_HTTP_FILTER_H_INCLUDED_
-
-
-#define NGX_HTTP_FILTER_NEED_IN_MEMORY 1
-#define NGX_HTTP_FILTER_SSI_NEED_IN_MEMORY 2
-#define NGX_HTTP_FILTER_NEED_TEMP 4
-#define NGX_HTTP_FILTER_ALLOW_RANGES 8
-
-
-typedef int (*ngx_http_output_header_filter_pt)(ngx_http_request_t *r);
-typedef int (*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;
-
-
-#endif /* _NGX_HTTP_FILTER_H_INCLUDED_ */
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 97e1b9439..98fbc28a6 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -90,7 +90,7 @@ void ngx_http_init_connection(ngx_connection_t *c)
/* STUB: epoll edge */ c->write->event_handler = ngx_http_empty_handler;
if (rev->ready) {
- /* deferred accept, aio, iocp */
+ /* the deferred accept(), rtsig, aio, iocp */
if (ngx_accept_mutex) {
if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
@@ -1542,10 +1542,12 @@ int ngx_http_send_last(ngx_http_request_t *r)
void ngx_http_close_request(ngx_http_request_t *r, int error)
{
- ngx_uint_t i;
- ngx_log_t *log;
- ngx_http_log_ctx_t *ctx;
- ngx_http_cleanup_t *cleanup;
+ ngx_uint_t i;
+ ngx_log_t *log;
+ ngx_http_log_ctx_t *ctx;
+ ngx_http_cleanup_t *cleanup;
+ ngx_http_core_loc_conf_t *clcf;
+ struct linger l;
log = r->connection->log;
@@ -1610,6 +1612,22 @@ void ngx_http_close_request(ngx_http_request_t *r, int error)
}
}
+ if (r->connection->timedout) {
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+
+ if (clcf->reset_timedout_connection) {
+ l.l_onoff = 1;
+ l.l_linger = 0;
+
+ if (setsockopt(r->connection->fd, SOL_SOCKET, SO_LINGER,
+ (const void *) &l, sizeof(struct linger)) == -1)
+ {
+ ngx_log_error(NGX_LOG_ALERT, log, ngx_socket_errno,
+ "setsockopt(SO_LINGER) failed");
+ }
+ }
+ }
+
/* ctx->url was allocated from r->pool */
ctx = log->data;
ctx->url = NULL;
@@ -1676,6 +1694,7 @@ static void ngx_http_client_error(ngx_http_request_t *r,
if (error == NGX_HTTP_REQUEST_TIME_OUT) {
ngx_log_error(NGX_LOG_INFO, r->connection->log, NGX_ETIMEDOUT,
"client timed out");
+ r->connection->timedout = 1;
ngx_http_close_request(r, error);
ngx_http_close_connection(r->connection);
return;
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index cac8aed37..3cf7307b2 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -287,8 +287,10 @@ struct ngx_http_request_s {
unsigned lingering_close:1;
unsigned closed:1;
- /* TODO: use the filter flags or the separate bits ???? */
- u_int filter;
+ unsigned filter_need_in_memory:1;
+ unsigned filter_ssi_need_in_memory:1;
+ unsigned filter_need_temporary:1;
+ unsigned filter_allow_ranges:1;
/* used to parse HTTP headers */
ngx_int_t state;
diff --git a/src/os/unix/ngx_alloc.c b/src/os/unix/ngx_alloc.c
new file mode 100644
index 000000000..69925d1be
--- /dev/null
+++ b/src/os/unix/ngx_alloc.c
@@ -0,0 +1,75 @@
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+int ngx_pagesize;
+
+
+void *ngx_alloc(size_t size, ngx_log_t *log)
+{
+ void *p;
+
+ if (!(p = malloc(size))) {
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
+ "malloc() " SIZE_T_FMT " bytes failed", size);
+ }
+
+ ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0,
+ "malloc: " PTR_FMT ":" SIZE_T_FMT, p, size);
+
+ return p;
+}
+
+
+void *ngx_calloc(size_t size, ngx_log_t *log)
+{
+ void *p;
+
+ p = ngx_alloc(size, log);
+
+ if (p) {
+ ngx_memzero(p, size);
+ }
+
+ return p;
+}
+
+
+#if (HAVE_POSIX_MEMALIGN)
+
+void *ngx_memalign(size_t aligment, size_t size, ngx_log_t *log)
+{
+ void *p;
+
+ if (posix_memalign(&p, aligment, size) == -1) {
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
+ "posix_memalign() " SIZE_T_FMT " bytes aligned to "
+ SIZE_T_FMT " failed", size, alignment);
+ }
+
+ ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0,
+ "posix_memalign: " PTR_FMT ":" SIZE_T_FMT, p, size);
+
+ return p;
+}
+
+#esif (HAVE_MEMALIGN)
+
+void *ngx_memalign(size_t aligment, size_t size, ngx_log_t *log)
+{
+ void *p;
+
+ if (!(p = memalign(aligment, size))) {
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
+ "memalign() " SIZE_T_FMT " bytes aligned to "
+ SIZE_T_FMT " failed", size, alignment);
+ }
+
+ ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0,
+ "memalign: " PTR_FMT ":" SIZE_T_FMT, p, size);
+
+ return p;
+}
+
+#endif
diff --git a/src/os/unix/ngx_alloc.h b/src/os/unix/ngx_alloc.h
new file mode 100644
index 000000000..650f8bef3
--- /dev/null
+++ b/src/os/unix/ngx_alloc.h
@@ -0,0 +1,36 @@
+#ifndef _NGX_ALLOC_H_INCLUDED_
+#define _NGX_ALLOC_H_INCLUDED_
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+void *ngx_alloc(size_t size, ngx_log_t *log);
+void *ngx_calloc(size_t size, ngx_log_t *log);
+
+#define ngx_free free
+
+
+/*
+ * Linux has memalign() or posix_memalign()
+ * Solaris has memalign()
+ * FreeBSD has not memalign() or posix_memalign() but its malloc() alignes
+ * allocations bigger than page size at page boundary.
+ */
+
+#if (HAVE_POSIX_MEMALIGN || HAVE_MEMALIGN)
+
+void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log);
+
+#else
+
+#define ngx_memalign(alignment, size, log) ngx_alloc(size, log)
+
+#endif
+
+
+extern int ngx_pagesize;
+
+
+#endif /* _NGX_ALLOC_H_INCLUDED_ */
diff --git a/src/os/unix/ngx_freebsd_rfork_thread.c b/src/os/unix/ngx_freebsd_rfork_thread.c
index 1cdfee4e9..740fb525d 100644
--- a/src/os/unix/ngx_freebsd_rfork_thread.c
+++ b/src/os/unix/ngx_freebsd_rfork_thread.c
@@ -30,7 +30,7 @@ char *ngx_freebsd_kern_usrstack;
size_t ngx_thread_stack_size;
-static size_t rz_size = /* STUB: PAGE_SIZE */ 4096;
+static size_t rz_size;
static size_t usable_stack_size;
static char *last_stack;
@@ -187,6 +187,7 @@ ngx_int_t ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle)
}
/* the main thread stack red zone */
+ rz_size = ngx_pagesize;
red_zone = ngx_freebsd_kern_usrstack - (size + rz_size);
ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0,
diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c
index 65c04a959..dc96ddd85 100644
--- a/src/os/unix/ngx_posix_init.c
+++ b/src/os/unix/ngx_posix_init.c
@@ -60,6 +60,8 @@ int ngx_posix_init(ngx_log_t *log)
struct rlimit rlmt;
struct sigaction sa;
+ ngx_pagesize = getpagesize();
+
for (sig = signals; sig->signo != 0; sig++) {
ngx_memzero(&sa, sizeof(struct sigaction));
sa.sa_handler = sig->handler;
diff --git a/src/os/unix/ngx_socket.c b/src/os/unix/ngx_socket.c
index 69d3f459b..443c93bbf 100644
--- a/src/os/unix/ngx_socket.c
+++ b/src/os/unix/ngx_socket.c
@@ -9,7 +9,9 @@
* a previous state using fcntl(F_GETFL).
*
* ioctl() and fcntl() are syscalls on at least FreeBSD 2.x, Linux 2.2
- * and Solaris 7
+ * and Solaris 7.
+ *
+ * ioctl() in Linux 2.4 and 2.6 uses BKL, however fcntl(F_SETFL) uses it too.
*/
diff --git a/src/os/unix/ngx_time.h b/src/os/unix/ngx_time.h
index 0b44c5ad4..dbb7a0a54 100644
--- a/src/os/unix/ngx_time.h
+++ b/src/os/unix/ngx_time.h
@@ -38,7 +38,7 @@ typedef struct tm ngx_tm_t;
#if (SOLARIS)
#define HAVE_TIMEZONE 1
-#define ngx_timezone() (-((daylight) ? altzone : timezone) / 60)
+#define ngx_timezone() (- (daylight ? altzone : timezone) / 60)
#elif defined __linux__
#define HAVE_TIMEZONE 1
diff --git a/src/os/win32/ngx_alloc.c b/src/os/win32/ngx_alloc.c
new file mode 100644
index 000000000..591e61bcb
--- /dev/null
+++ b/src/os/win32/ngx_alloc.c
@@ -0,0 +1,36 @@
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+int ngx_pagesize;
+
+
+void *ngx_alloc(size_t size, ngx_log_t *log)
+{
+ void *p;
+
+ if (!(p = malloc(size))) {
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
+ "malloc() " SIZE_T_FMT " bytes failed", size);
+ }
+
+ ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0,
+ "malloc: " PTR_FMT ":" SIZE_T_FMT, p, size);
+
+ return p;
+}
+
+
+void *ngx_calloc(size_t size, ngx_log_t *log)
+{
+ void *p;
+
+ p = ngx_alloc(size, log);
+
+ if (p) {
+ ngx_memzero(p, size);
+ }
+
+ return p;
+}
diff --git a/src/os/win32/ngx_alloc.h b/src/os/win32/ngx_alloc.h
new file mode 100644
index 000000000..d6ea00a2b
--- /dev/null
+++ b/src/os/win32/ngx_alloc.h
@@ -0,0 +1,18 @@
+#ifndef _NGX_ALLOC_H_INCLUDED_
+#define _NGX_ALLOC_H_INCLUDED_
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+void *ngx_alloc(size_t size, ngx_log_t *log);
+void *ngx_calloc(size_t size, ngx_log_t *log);
+
+#define ngx_free free
+#define ngx_memalign(alignment, size, log) ngx_alloc(size, log)
+
+extern int ngx_pagesize;
+
+
+#endif /* _NGX_ALLOC_H_INCLUDED_ */
diff --git a/src/os/win32/ngx_win32_init.c b/src/os/win32/ngx_win32_init.c
index c4ffc1121..7a25b2845 100644
--- a/src/os/win32/ngx_win32_init.c
+++ b/src/os/win32/ngx_win32_init.c
@@ -40,6 +40,7 @@ int ngx_os_init(ngx_log_t *log)
DWORD bytes;
SOCKET s;
WSADATA wsd;
+ SYSTEM_INFO si;
OSVERSIONINFOEX osvi;
ngx_osviex_stub_t *osviex_stub;
@@ -121,6 +122,9 @@ int ngx_os_init(ngx_log_t *log)
}
}
+ GetSystemInfo(&si);
+ ngx_pagesize = si.dwPageSize;
+
/* init Winsock */