nginx-0.0.3-2004-04-08-19:58:25 import

This commit is contained in:
Igor Sysoev 2004-04-08 15:58:25 +00:00
parent 9a864bd8f8
commit fff32326ca
13 changed files with 228 additions and 106 deletions

View File

@ -40,14 +40,14 @@ if [ $MD5 != NONE ]; then
else
ngx_lib_inc="#include <sys/types.h>
#include <md5.h>"
if [ $PLATFORM != win32 ]; then
MD5=NO
# Solaris 8/9
ngx_lib="rsaref md5"
ngx_lib_inc="#include <sys/types.h>
#include <md5.h>"
ngx_lib="rsaref md5 library"
ngx_lib_test="MD5_CTX md5; MD5Init(&md5)"
ngx_libs=-lmd5
. auto/lib/test
@ -62,7 +62,7 @@ ngx_lib_inc="#include <sys/types.h>
else
# FreeBSD
ngx_lib="rsaref md"
ngx_lib="rsaref md library"
ngx_lib_test="MD5_CTX md5; MD5Init(&md5)"
ngx_libs=-lmd
. auto/lib/test
@ -79,7 +79,7 @@ ngx_lib_inc="#include <sys/types.h>
# OpenSSL crypto library
ngx_inc="#include <openssl/md5.h>"
ngx_lib="OpenSSL md5 crypto"
ngx_lib="OpenSSL md5 crypto library"
ngx_lib_test="MD5_CTX md5; MD5_Init(&md5)"
ngx_libs=-lcrypto
. auto/lib/test
@ -93,4 +93,6 @@ ngx_lib_inc="#include <sys/types.h>
MD5=YES
MD5_LIB=crypto
fi
fi
fi

View File

@ -40,9 +40,10 @@ if [ $PCRE != NONE ]; then
else
if [ $PLATFORM != win32 ]; then
ngx_lib_inc="#include <pcre.h>"
PCRE=NO
ngx_lib="PCRE"
ngx_lib_inc="#include <pcre.h>"
ngx_lib="PCRE library"
ngx_lib_test="pcre *re; pcre_compile(re, 0, NULL, 0, NULL)"
ngx_libs=-lpcre
. auto/lib/test
@ -50,14 +51,27 @@ else
if [ $ngx_found = yes ]; then
have=HAVE_PCRE . auto/have
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
CORE_LIBS="$CORE_LIBS $ngx_libs"
PCRE=YES
else
PCRE=NO
# FreeBSD PCRE port.
ngx_lib="PCRE library in /usr/local/"
ngx_lib_cflags="-I /usr/local/include"
. auto/lib/test
fi
if [ $ngx_found = yes ]; then
have=HAVE_PCRE . auto/have
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_INCS="$CORE_INCS /usr/local/include"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
CORE_LIBS="$CORE_LIBS $ngx_libs"
PCRE=YES
fi
fi

View File

@ -1,5 +1,5 @@
echo $ngx_n "checking for $ngx_lib library ..." $ngx_c
echo $ngx_n "checking for $ngx_lib ..." $ngx_c
echo >> $NGX_ERR
echo "checking for $ngx_lib library" >> $NGX_ERR
@ -8,7 +8,8 @@ ngx_found=no
echo "$ngx_lib_inc" > $NGX_AUTOTEST.c
echo "int main() { $ngx_lib_test; return 0; }" >> $NGX_AUTOTEST.c
eval "$CC $cc_test_flags -o $NGX_AUTOTEST $NGX_AUTOTEST.c $ngx_libs \
eval "$CC $cc_test_flags $ngx_lib_cflags \
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $ngx_libs \
>> $NGX_ERR 2>&1"
if [ -x $NGX_AUTOTEST ]; then

View File

@ -34,9 +34,10 @@ if [ $ZLIB != NONE ]; then
else
if [ $PLATFORM != win32 ]; then
ngx_lib_inc="#include <zlib.h>"
ngx_lib="zlib"
ngx_lib="zlib library"
ngx_lib_test="z_stream z; deflate(&z, Z_NO_FLUSH)"
ngx_libs=-lz
. auto/lib/test
@ -48,5 +49,6 @@ else
else
ZLIB=NO
fi
fi
fi

View File

@ -23,7 +23,8 @@
#define NGX_LOG_DEBUG_FIRST NGX_LOG_DEBUG_CORE
#define NGX_LOG_DEBUG_LAST NGX_LOG_DEBUG_HTTP
#define NGX_LOG_DEBUG_ALL 0xfffffff0
#define NGX_LOG_DEBUG_CONNECTION 0x80000000
#define NGX_LOG_DEBUG_ALL 0x7ffffff0
/*

View File

@ -22,6 +22,8 @@ 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_inline void ngx_kqueue_dump_event(ngx_log_t *log,
struct kevent *kev);
static void *ngx_kqueue_create_conf(ngx_cycle_t *cycle);
static char *ngx_kqueue_init_conf(ngx_cycle_t *cycle, void *conf);
@ -443,17 +445,7 @@ static ngx_int_t ngx_kqueue_process_events(ngx_cycle_t *cycle)
for (i = 0; i < events; i++) {
ngx_log_debug6(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
(event_list[i].ident > 0x8000000
&& event_list[i].ident != (unsigned) -1) ?
"kevent: " PTR_FMT ": ft:%d fl:%04X ff:%08X d:%d ud:"
PTR_FMT:
"kevent: %d: ft:%d fl:%04X ff:%08X d:%d ud:" PTR_FMT,
event_list[i].ident, event_list[i].filter,
event_list[i].flags, event_list[i].fflags,
event_list[i].data, event_list[i].udata);
ngx_kqueue_dump_event(cycle->log, &event_list[i]);
if (event_list[i].flags & EV_ERROR) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, event_list[i].data,
@ -472,6 +464,10 @@ static ngx_int_t ngx_kqueue_process_events(ngx_cycle_t *cycle)
ev = (ngx_event_t *) ((uintptr_t) ev & (uintptr_t) ~1);
ev->returned_instance = instance;
if (ev->log && (ev->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
ngx_kqueue_dump_event(ev->log, &event_list[i]);
}
if (!ev->active || ev->instance != instance) {
/*
@ -560,6 +556,19 @@ 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)
{
ngx_log_debug6(NGX_LOG_DEBUG_EVENT, log, 0,
(kev->ident > 0x8000000 && kev->ident != (unsigned) -1) ?
"kevent: " PTR_FMT ": ft:%d fl:%04X ff:%08X d:%d ud:"
PTR_FMT:
"kevent: %d: ft:%d fl:%04X ff:%08X d:%d ud:" PTR_FMT,
kev->ident, kev->filter,
kev->flags, kev->fflags,
kev->data, kev->udata);
}
static void *ngx_kqueue_create_conf(ngx_cycle_t *cycle)
{
ngx_kqueue_conf_t *kcf;

View File

@ -35,6 +35,8 @@ static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static char *ngx_event_connections(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static char *ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
static void *ngx_event_create_conf(ngx_cycle_t *cycle);
static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf);
@ -117,6 +119,13 @@ static ngx_command_t ngx_event_core_commands[] = {
offsetof(ngx_event_conf_t, accept_mutex_delay),
NULL },
{ ngx_string("debug_connection"),
NGX_EVENT_CONF|NGX_CONF_TAKE1,
ngx_event_debug_connection,
0,
0,
NULL },
ngx_null_command
};
@ -517,6 +526,52 @@ static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
static char *ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf)
{
#if (NGX_DEBUG)
ngx_event_conf_t *ecf = conf;
in_addr_t *addr;
ngx_str_t *value;
struct hostent *h;
value = cf->args->elts;
/* AF_INET only */
if (!(addr = ngx_push_array(&ecf->debug_connection))) {
return NGX_CONF_ERROR;
}
*addr = inet_addr((char *) value[1].data);
if (*addr != INADDR_NONE) {
return NGX_OK;
}
h = gethostbyname((char *) value[1].data);
if (h == NULL || h->h_addr_list[0] == NULL) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"host %s not found", value[1].data);
return NGX_CONF_ERROR;
}
*addr = *(in_addr_t *)(h->h_addr_list[0]);
#else
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
"\"debug_connection\" is ignored, you need to rebuild "
"nginx using --with-debug option to enable it");
#endif
return NGX_OK;
}
static void *ngx_event_create_conf(ngx_cycle_t *cycle)
{
ngx_event_conf_t *ecf;
@ -531,6 +586,11 @@ static void *ngx_event_create_conf(ngx_cycle_t *cycle)
ecf->accept_mutex_delay = NGX_CONF_UNSET_MSEC;
ecf->name = (void *) NGX_CONF_UNSET;
#if (NGX_DEBUG)
ngx_init_array(ecf->debug_connection, cycle->pool, 5, sizeof(in_addr_t),
NGX_CONF_ERROR);
#endif
return ecf;
}

View File

@ -390,6 +390,10 @@ typedef struct {
ngx_msec_t accept_mutex_delay;
u_char *name;
#if (NGX_DEBUG)
ngx_array_t debug_connection;
#endif
} ngx_event_conf_t;

View File

@ -275,6 +275,25 @@ void ngx_event_accept(ngx_event_t *ev)
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"accept: fd:%d c:%d", s, c->number);
#if (NGX_DEBUG)
{
uint32_t *addr;
in_addr_t i;
struct sockaddr_in *addr_in;
addr_in = (struct sockaddr_in *) sa;
addr = ecf->debug_connection.elts;
for (i = 0; i < ecf->debug_connection.nelts; i++) {
if (addr[i] == addr_in->sin_addr.s_addr) {
log->log_level = NGX_LOG_DEBUG_CONNECTION|NGX_LOG_DEBUG_ALL;
break;
}
}
}
#endif
if (ngx_add_conn) {
if (ngx_add_conn(c) == NGX_ERROR) {
if (ngx_close_socket(s) == -1) {

View File

@ -62,6 +62,12 @@ static int ngx_http_charset_header_filter(ngx_http_request_t *r)
{
ngx_http_charset_loc_conf_t *lcf;
lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module);
if (lcf->default_charset.len == 0) {
return ngx_http_next_header_filter(r);
}
if (r->headers_out.content_type == NULL
|| ngx_strncasecmp(r->headers_out.content_type->value.data,
"text/", 5) != 0
@ -72,8 +78,6 @@ static int ngx_http_charset_header_filter(ngx_http_request_t *r)
return ngx_http_next_header_filter(r);
}
lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module);
if (r->headers_out.status == NGX_HTTP_MOVED_PERMANENTLY
&& r->headers_out.status == NGX_HTTP_MOVED_TEMPORARILY)
{
@ -135,7 +139,7 @@ static char *ngx_http_charset_merge_loc_conf(ngx_conf_t *cf,
ngx_http_charset_loc_conf_t *conf = child;
ngx_conf_merge_str_value(conf->default_charset,
prev->default_charset, "koi8-r");
prev->default_charset, "");
return NGX_CONF_OK;
}

View File

@ -482,7 +482,9 @@ int ngx_http_find_location_config(ngx_http_request_t *r)
r->loc_conf = clcfp[i]->loc_conf;
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
r->connection->log->file = clcf->err_log->file;
if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
r->connection->log->log_level = clcf->err_log->log_level;
}
if (clcfp[i]->exact_match && r->uri.len == clcfp[i]->name.len) {
#if (HAVE_PCRE)
@ -529,7 +531,9 @@ int ngx_http_find_location_config(ngx_http_request_t *r)
r->loc_conf = clcfp[i]->loc_conf;
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
r->connection->log->file = clcf->err_log->file;
if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
r->connection->log->log_level = clcf->err_log->log_level;
}
break;
}

View File

@ -231,7 +231,9 @@ static void ngx_http_init_request(ngx_event_t *rev)
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
c->log->file = clcf->err_log->file;
if (!(c->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
c->log->log_level = clcf->err_log->log_level;
}
if (c->buffer == NULL) {
c->buffer = ngx_create_temp_hunk(c->pool,

View File

@ -133,7 +133,7 @@ int ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
* the size of the hunks is smaller than "postpone_output" directive
*/
if (!last && flush == 0 && size < conf->postpone_output) {
if (!last && flush == 0 && size < (off_t) conf->postpone_output) {
return NGX_OK;
}