]> git.kaiwu.me - nginx.git/commitdiff
nginx-0.0.3-2004-04-08-19:58:25 import
authorIgor Sysoev <igor@sysoev.ru>
Thu, 8 Apr 2004 15:58:25 +0000 (15:58 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Thu, 8 Apr 2004 15:58:25 +0000 (15:58 +0000)
13 files changed:
auto/lib/md5/conf
auto/lib/pcre/conf
auto/lib/test
auto/lib/zlib/conf
src/core/ngx_log.h
src/event/modules/ngx_kqueue_module.c
src/event/ngx_event.c
src/event/ngx_event.h
src/event/ngx_event_accept.c
src/http/modules/ngx_http_charset_filter.c
src/http/ngx_http_core_module.c
src/http/ngx_http_request.c
src/http/ngx_http_write_filter.c

index d5b2a0afdb073af4dd4b0e6d0dafe3af7153e145..8871038b05a011cc0e25605b9c8e5b583b877377 100644 (file)
@@ -40,57 +40,59 @@ if [ $MD5 != NONE ]; then
 
 else
 
-ngx_lib_inc="#include <sys/types.h>
-#include <md5.h>"
-
-    MD5=NO
-
-    # Solaris 8/9
-
-    ngx_lib="rsaref md5"
-    ngx_lib_test="MD5_CTX md5; MD5Init(&md5)"
-    ngx_libs=-lmd5
-    . auto/lib/test
-
+    if [ $PLATFORM != win32 ]; then
+            MD5=NO
 
-    if [ $ngx_found = yes ]; then
-        CORE_LIBS="$CORE_LIBS $ngx_libs"
-        MD5=YES
-        MD5_LIB=md5
-        ngx_found=no
-
-    else
-        # FreeBSD
-
-        ngx_lib="rsaref md"
-        ngx_lib_test="MD5_CTX md5; MD5Init(&md5)"
-        ngx_libs=-lmd
-        . auto/lib/test
-    fi
+            # Solaris 8/9
 
-
-    if [ $ngx_found = yes ]; then
-        CORE_LIBS="$CORE_LIBS $ngx_libs"
-        MD5=YES
-        MD5_LIB=md
-        ngx_found=no
-
-    else
-        # OpenSSL crypto library
-
-        ngx_inc="#include <openssl/md5.h>"
-        ngx_lib="OpenSSL md5 crypto"
-        ngx_lib_test="MD5_CTX md5; MD5_Init(&md5)"
-        ngx_libs=-lcrypto
-        . auto/lib/test
+            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
+
+
+        if [ $ngx_found = yes ]; then
+            CORE_LIBS="$CORE_LIBS $ngx_libs"
+            MD5=YES
+            MD5_LIB=md5
+            ngx_found=no
+
+        else
+            # FreeBSD
+
+            ngx_lib="rsaref md library"
+            ngx_lib_test="MD5_CTX md5; MD5Init(&md5)"
+            ngx_libs=-lmd
+            . auto/lib/test
+        fi
+
+
+        if [ $ngx_found = yes ]; then
+            CORE_LIBS="$CORE_LIBS $ngx_libs"
+            MD5=YES
+            MD5_LIB=md
+            ngx_found=no
+
+        else
+            # OpenSSL crypto library
+
+            ngx_inc="#include <openssl/md5.h>"
+            ngx_lib="OpenSSL md5 crypto library"
+            ngx_lib_test="MD5_CTX md5; MD5_Init(&md5)"
+            ngx_libs=-lcrypto
+            . auto/lib/test
+        fi
+
+
+        if [ $ngx_found = yes ]; then
+            have=HAVE_OPENSSL_MD5 . auto/have
+            have=HAVE_OPENSSL_MD5_H . auto/have
+            CORE_LIBS="$CORE_LIBS $ngx_libs"
+            MD5=YES
+            MD5_LIB=crypto
+        fi
     fi
 
-
-    if [ $ngx_found = yes ]; then
-        have=HAVE_OPENSSL_MD5 . auto/have
-        have=HAVE_OPENSSL_MD5_H . auto/have
-        CORE_LIBS="$CORE_LIBS $ngx_libs"
-        MD5=YES
-        MD5_LIB=crypto
-    fi
 fi
index fa50c24e95da684b196705e063c2d2128866e46f..a907e8b505265127d1514287571c4b766cd6e9c3 100644 (file)
@@ -40,24 +40,38 @@ if [ $PCRE != NONE ]; then
 else
 
     if [ $PLATFORM != win32 ]; then
-        ngx_lib_inc="#include <pcre.h>"
+            PCRE=NO
 
-        ngx_lib="PCRE"
-        ngx_lib_test="pcre *re; pcre_compile(re, 0, NULL, 0, NULL)"
-        ngx_libs=-lpcre
-        . auto/lib/test
+            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
 
 
         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
 
index d030655e19e768256a0e8da557c79420a1cb9c02..3519a6c5c2c2dde971bd4f6d81a824951f2a8494 100644 (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
index 7376abd70878eafe4237fa7035475de3bce79a0f..9c2178fad8a5206b9561f838023ea65a77d7a296 100644 (file)
@@ -34,19 +34,21 @@ if [ $ZLIB != NONE ]; then
 
 else
 
-    ngx_lib_inc="#include <zlib.h>"
+    if [ $PLATFORM != win32 ]; then
+        ngx_lib_inc="#include <zlib.h>"
 
-    ngx_lib="zlib"
-    ngx_lib_test="z_stream z; deflate(&z, Z_NO_FLUSH)"
-    ngx_libs=-lz
-    . auto/lib/test
+        ngx_lib="zlib library"
+        ngx_lib_test="z_stream z; deflate(&z, Z_NO_FLUSH)"
+        ngx_libs=-lz
+        . auto/lib/test
 
 
-    if [ $ngx_found = yes ]; then
-        CORE_LIBS="$CORE_LIBS $ngx_libs"
-        ZLIB=YES
-    else
-        ZLIB=NO
+        if [ $ngx_found = yes ]; then
+            CORE_LIBS="$CORE_LIBS $ngx_libs"
+            ZLIB=YES
+        else
+            ZLIB=NO
+        fi
     fi
 
 fi
index d1fdab63d58bf0b2e6c82aa07267cdb8bac24e4c..87090dc09954bb12a921a336c340b36792e0157a 100644 (file)
@@ -6,24 +6,25 @@
 #include <ngx_core.h>
 
 
-#define NGX_LOG_STDERR          0
-#define NGX_LOG_EMERG           1
-#define NGX_LOG_ALERT           2
-#define NGX_LOG_CRIT            3
-#define NGX_LOG_ERR             4
-#define NGX_LOG_WARN            5
-#define NGX_LOG_NOTICE          6
-#define NGX_LOG_INFO            7
-#define NGX_LOG_DEBUG           8
-
-#define NGX_LOG_DEBUG_CORE      0x10
-#define NGX_LOG_DEBUG_ALLOC     0x20
-#define NGX_LOG_DEBUG_EVENT     0x40
-#define NGX_LOG_DEBUG_HTTP      0x80
-
-#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_STDERR            0
+#define NGX_LOG_EMERG             1
+#define NGX_LOG_ALERT             2
+#define NGX_LOG_CRIT              3
+#define NGX_LOG_ERR               4
+#define NGX_LOG_WARN              5
+#define NGX_LOG_NOTICE            6
+#define NGX_LOG_INFO              7
+#define NGX_LOG_DEBUG             8
+
+#define NGX_LOG_DEBUG_CORE        0x10
+#define NGX_LOG_DEBUG_ALLOC       0x20
+#define NGX_LOG_DEBUG_EVENT       0x40
+#define NGX_LOG_DEBUG_HTTP        0x80
+
+#define NGX_LOG_DEBUG_FIRST       NGX_LOG_DEBUG_CORE
+#define NGX_LOG_DEBUG_LAST        NGX_LOG_DEBUG_HTTP
+#define NGX_LOG_DEBUG_CONNECTION  0x80000000
+#define NGX_LOG_DEBUG_ALL         0x7ffffff0
 
 
 /*
index c339660dbf7bf52d0f0a4b5e9e30286f0695a103..abc577b1e70771e1394cacc162a028df3424b488 100644 (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;
index ebb56ce8443a376b23ef04991c74a2e14fa5912b..c5ea45d2c6cb0ce7261a8c4cdfb840e4e997ce40 100644 (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;
 }
 
index 1dcfe5066b22874973ccddbfb9c13bf18e328c93..433d6cffcdd91a49176e91cdca47610c6d267887 100644 (file)
@@ -381,15 +381,19 @@ extern ngx_event_actions_t   ngx_event_actions;
 
 
 typedef struct {
-    ngx_int_t    connections;
-    ngx_int_t    use;
+    ngx_int_t     connections;
+    ngx_int_t     use;
 
-    ngx_flag_t   multi_accept;
-    ngx_flag_t   accept_mutex;
+    ngx_flag_t    multi_accept;
+    ngx_flag_t    accept_mutex;
 
-    ngx_msec_t   accept_mutex_delay;
+    ngx_msec_t    accept_mutex_delay;
 
-    u_char      *name;
+    u_char       *name;
+
+#if (NGX_DEBUG)
+    ngx_array_t   debug_connection;
+#endif
 } ngx_event_conf_t;
 
 
index c955bbfa3c1564a85e16a3e675fd92ccafe82630..70db78d712d037916b70a68d5825e069a52dd935 100644 (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) {
index a545eafa184e56dc855835b015c5033fa5fee68c..052a1f82204ec4fd0c2e6a7b648cd0f3dfffc5d2 100644 (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;
 }
index 3ae61829f43b31277dc3d1ec12e03a0e17735bca..6b0db2625005936908bc7dfbfdca9ed0394a6eff 100644 (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;
-            r->connection->log->log_level = clcf->err_log->log_level;
+            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;
-            r->connection->log->log_level = clcf->err_log->log_level;
+            if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
+                r->connection->log->log_level = clcf->err_log->log_level;
+            }
 
             break;
         }
index a2a0feda62667f39a2d13462306b334b6d12a18b..9233f89d8a309cf1831b8a2e616cffd0a072af01 100644 (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;
-    c->log->log_level = clcf->err_log->log_level;
+    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,
index 5fa144fbcd6cbd24e5847e0318170fe16ed838bd..8c1a98a91f2523cb6df271a93ef30d1cf7148225 100644 (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;
     }