changeset 24:420dd3f9e703 NGINX_0_1_12

nginx 0.1.12 *) Feature: the %request_length log parameter. *) Bugfix: when using the /dev/poll, select and poll on the platforms, where these methods may do the false reports, there may be the long delay when the request was passed via the keep-alive connection. It may be at least on Solaris when using the /dev/poll. *) Bugfix: the send_lowat directive is ignored on Linux because Linux does not support the SO_SNDLOWAT option.
author Igor Sysoev <http://sysoev.ru>
date Mon, 06 Dec 2004 00:00:00 +0300
parents 5d37652cf26b
children 21488c53e135
files CHANGES CHANGES.ru src/core/nginx.h src/http/modules/ngx_http_index_handler.c src/http/ngx_http_log_handler.c src/http/ngx_http_request.c src/http/ngx_http_request.h src/http/ngx_http_request_body.c src/os/unix/ngx_linux_config.h src/os/unix/ngx_solaris_config.h
diffstat 10 files changed, 69 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,16 @@
+
+Changes with nginx 0.1.12                                        06 Dec 2004
+
+    *) Feature: the %request_length log parameter.
+
+    *) Bugfix: when using the /dev/poll, select and poll on the platforms, 
+       where these methods may do the false reports, there may be the long 
+       delay when the request was passed via the keep-alive connection. It 
+       may be at least on Solaris when using the /dev/poll.
+
+    *) Bugfix: the send_lowat directive is ignored on Linux because Linux 
+       does not support the SO_SNDLOWAT option.
+
 
 Changes with nginx 0.1.11                                        02 Dec 2004
 
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,3 +1,16 @@
+
+Изменения в nginx 0.1.12                                          06.12.2004
+
+    *) Добавление: параметр лога %request_length.
+
+    *) Исправление: при использовании /dev/poll, select и poll на платформах, 
+       где возможны ложные срабатывания указанных методов, могли быть 
+       длительные задержки при обработке запроса по keep-alive соединению. 
+       Наблюдалось по крайней мере на Solaris с использованием /dev/poll.
+
+    *) Исправление: директива send_lowat игнорируется на Linux, так как Linux 
+       не поддерживает опцию SO_SNDLOWAT.
+
 
 Изменения в nginx 0.1.11                                          02.12.2004
 
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define NGINX_VER          "nginx/0.1.11"
+#define NGINX_VER          "nginx/0.1.12"
 
 #define NGINX_VAR          "NGINX"
 #define NGX_NEWPID_EXT     ".newbin"
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -477,12 +477,12 @@ static char *ngx_http_index_merge_loc_co
         }
     }
 
-#endif
-
     if (conf->max_index_len < prev->max_index_len) {
         conf->max_index_len = prev->max_index_len;
     }
 
+#endif
+
     if (conf->index_cache == NULL) {
         conf->index_cache = prev->index_cache;
     }
--- a/src/http/ngx_http_log_handler.c
+++ b/src/http/ngx_http_log_handler.c
@@ -28,6 +28,8 @@ static u_char *ngx_http_log_length(ngx_h
                                    uintptr_t data);
 static u_char *ngx_http_log_apache_length(ngx_http_request_t *r, u_char *buf,
                                           uintptr_t data);
+static u_char *ngx_http_log_request_length(ngx_http_request_t *r, u_char *buf,
+                                           uintptr_t data);
 static u_char *ngx_http_log_header_in(ngx_http_request_t *r, u_char *buf,
                                       uintptr_t data);
 static u_char *ngx_http_log_connection_header_out(ngx_http_request_t *r,
@@ -118,6 +120,8 @@ ngx_http_log_op_name_t ngx_http_log_fmt_
     { ngx_string("status"), 3, ngx_http_log_status },
     { ngx_string("length"), NGX_OFF_T_LEN, ngx_http_log_length },
     { ngx_string("apache_length"), NGX_OFF_T_LEN, ngx_http_log_apache_length },
+    { ngx_string("request_length"), NGX_OFF_T_LEN,
+                                    ngx_http_log_request_length },
     { ngx_string("i"), NGX_HTTP_LOG_ARG, ngx_http_log_header_in },
     { ngx_string("o"), NGX_HTTP_LOG_ARG, ngx_http_log_header_out },
     { ngx_null_string, 0, NULL }
@@ -283,6 +287,13 @@ static u_char *ngx_http_log_apache_lengt
 }
 
 
+static u_char *ngx_http_log_request_length(ngx_http_request_t *r, u_char *buf,
+                                           uintptr_t data)
+{
+    return ngx_sprintf(buf, "%O", r->request_length);
+}
+
+
 static u_char *ngx_http_log_header_in(ngx_http_request_t *r, u_char *buf,
                                       uintptr_t data)
 {
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -795,6 +795,8 @@ static void ngx_http_process_request_hea
             ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                            "http header done");
 
+            r->request_length += r->header_in->pos - r->header_in->start;
+
             r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE;
 
             rc = ngx_http_process_request_header(r);
@@ -922,6 +924,8 @@ static ngx_int_t ngx_http_alloc_large_he
 
         /* the client fills up the buffer with "\r\n" */
 
+        r->request_length += r->header_in->end - r->header_in->start;
+
         r->header_in->pos = r->header_in->start;
         r->header_in->last = r->header_in->start;
 
@@ -981,6 +985,8 @@ static ngx_int_t ngx_http_alloc_large_he
          * to relocate the parser header pointers
          */
 
+        r->request_length += r->header_in->end - r->header_in->start;
+
         r->header_in = b;
 
         return NGX_OK;
@@ -989,6 +995,8 @@ static ngx_int_t ngx_http_alloc_large_he
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                    "http large header copy: %d", r->header_in->pos - old);
 
+    r->request_length += old - r->header_in->start;
+
     new = b->start;
 
     ngx_memcpy(new, old, r->header_in->pos - old);
@@ -1810,6 +1818,10 @@ static void ngx_http_keepalive_handler(n
     c->log_error = NGX_ERROR_INFO;
 
     if (n == NGX_AGAIN) {
+        if (ngx_handle_level_read_event(rev) == NGX_ERROR) {
+            ngx_http_close_connection(c);
+        }
+
         return;
     }
 
@@ -1932,6 +1944,11 @@ static void ngx_http_lingering_close_han
 
     } while (rev->ready);
 
+    if (ngx_handle_level_read_event(rev) == NGX_ERROR) {
+        ngx_http_close_connection(c);
+        return;
+    }
+
     clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
 
     timer *= 1000;
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -298,6 +298,8 @@ struct ngx_http_request_s {
     /* used to learn the Apache compatible response length without a header */
     size_t               header_size;
 
+    size_t               request_length;
+
     u_char              *discarded_buffer;
     void               **err_ctx;
     ngx_uint_t           err_status;
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -42,6 +42,7 @@ ngx_int_t ngx_http_read_client_request_b
             /* the whole request body was pre-read */
 
             r->header_in->pos += r->headers_in.content_length_n;
+            r->request_length += r->headers_in.content_length_n;
 
             r->request_body->handler(r->request_body->data);
 
@@ -49,6 +50,7 @@ ngx_int_t ngx_http_read_client_request_b
         }
 
         r->header_in->pos = r->header_in->last;
+        r->request_length += size;
     }
 
 
@@ -173,6 +175,7 @@ static ngx_int_t ngx_http_do_read_client
 
         r->request_body->buf->last += n;
         r->request_body->rest -= n;
+        r->request_length += n;
 
         if (r->request_body->rest == 0) {
             break;
--- a/src/os/unix/ngx_linux_config.h
+++ b/src/os/unix/ngx_linux_config.h
@@ -80,6 +80,12 @@ extern ssize_t sendfile(int s, int fd, i
 #endif
 
 
+#ifndef NGX_HAVE_SO_SNDLOWAT
+/* setsockopt(SO_SNDLOWAT) returns ENOPROTOOPT */
+#define NGX_HAVE_SO_SNDLOWAT         0
+#endif
+
+
 #ifndef NGX_HAVE_INHERITED_NONBLOCK
 #define NGX_HAVE_INHERITED_NONBLOCK  0
 #endif
--- a/src/os/unix/ngx_solaris_config.h
+++ b/src/os/unix/ngx_solaris_config.h
@@ -76,7 +76,7 @@
 
 
 #ifndef NGX_HAVE_SO_SNDLOWAT
-/* setsockopt(SO_SNDLOWAT) returns error "Option not supported by protocol" */
+/* setsockopt(SO_SNDLOWAT) returns ENOPROTOOPT */
 #define NGX_HAVE_SO_SNDLOWAT         0
 #endif