nginx-0.0.3-2004-06-06-23:49:18 import

This commit is contained in:
Igor Sysoev 2004-06-06 19:49:18 +00:00
parent 6e1bbd7896
commit 0ab91b9012
33 changed files with 318 additions and 120 deletions

View File

@ -5,7 +5,7 @@ case $CC in
*gcc*)
# gcc 2.7.2.3, 2.8.1, 2.95.4,
# 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4
# 3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4
# optimization
#CFLAGS="$CFLAGS -O2 -fomit-frame-pointer"

View File

@ -8,7 +8,7 @@ CORE_DEPS="src/core/nginx.h \
src/core/ngx_core.h \
src/core/ngx_atomic.h \
src/core/ngx_log.h \
src/core/ngx_alloc.h \
src/core/ngx_palloc.h \
src/core/ngx_array.h \
src/core/ngx_table.h \
src/core/ngx_buf.h \
@ -27,7 +27,7 @@ CORE_DEPS="src/core/nginx.h \
CORE_SRCS="src/core/nginx.c \
src/core/ngx_log.c \
src/core/ngx_alloc.c \
src/core/ngx_palloc.c \
src/core/ngx_array.c \
src/core/ngx_buf.c \
src/core/ngx_output_chain.c \
@ -103,6 +103,7 @@ UNIX_DEPS="$CORE_DEPS $EVENT_DEPS \
src/os/unix/ngx_time.h \
src/os/unix/ngx_types.h \
src/os/unix/ngx_errno.h \
src/os/unix/ngx_alloc.h \
src/os/unix/ngx_files.h \
src/os/unix/ngx_process.h \
src/os/unix/ngx_thread.h \
@ -113,6 +114,7 @@ UNIX_DEPS="$CORE_DEPS $EVENT_DEPS \
UNIX_SRCS="$CORE_SRCS $EVENT_SRCS \
src/os/unix/ngx_time.c \
src/os/unix/ngx_errno.c \
src/os/unix/ngx_alloc.c \
src/os/unix/ngx_files.c \
src/os/unix/ngx_socket.c \
src/os/unix/ngx_recv.c \
@ -146,6 +148,7 @@ WIN32_DEPS="$CORE_DEPS $EVENT_DEPS \
src/os/win32/ngx_time.h \
src/os/win32/ngx_types.h \
src/os/win32/ngx_errno.h \
src/os/win32/ngx_alloc.h \
src/os/win32/ngx_files.h \
src/os/win32/ngx_process.h \
src/os/win32/ngx_socket.h \
@ -156,6 +159,7 @@ WIN32_CONFIG=src/os/win32/ngx_win32_config.h
WIN32_SRCS="$CORE_SRCS $EVENT_SRCS \
src/os/win32/ngx_errno.c \
src/os/win32/ngx_alloc.c \
src/os/win32/ngx_files.c \
src/os/win32/ngx_time.c \
src/os/win32/ngx_process.c \
@ -194,7 +198,6 @@ HTTP_INCS="src/http src/http/modules"
HTTP_DEPS="src/http/ngx_http.h \
src/http/ngx_http_request.h \
src/http/ngx_http_filter.h \
src/http/ngx_http_config.h \
src/http/ngx_http_core_module.h \
src/http/ngx_http_cache.h \

View File

@ -110,3 +110,15 @@ ngx_func="localtime_r()"
ngx_func_inc="#include <time.h>"
ngx_func_test="struct tm t; time_t c=0; localtime_r(&c, &t)"
. auto/func
ngx_func="posix_memalign()"
ngx_func_inc="#include <stdlib.h>"
ngx_func_test="void *p, int n; n = posix_memalign(&p, 4096, 4096)"
. auto/func
ngx_func="memalign()"
ngx_func_inc="#include <stdlib.h>"
ngx_func_test="void *p; p = memalign(4096, 4096)"
. auto/func

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

75
src/os/unix/ngx_alloc.c Normal file
View File

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

36
src/os/unix/ngx_alloc.h Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

36
src/os/win32/ngx_alloc.c Normal file
View File

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

18
src/os/win32/ngx_alloc.h Normal file
View File

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

View File

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