nginx-0.0.1-2004-01-05-23:55:48 import
diff --git a/src/http/modules/ngx_http_rewrite_handler.c b/src/http/modules/ngx_http_rewrite_handler.c
index 03414aa..e06b54b 100644
--- a/src/http/modules/ngx_http_rewrite_handler.c
+++ b/src/http/modules/ngx_http_rewrite_handler.c
@@ -113,7 +113,7 @@
         if (rc == NGX_DECLINED) {
             if (scf->log) {
                 ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
-                              "\"%s\" is not matched", rule[i].re_name.data);
+                              "\"%s\" does not match", rule[i].re_name.data);
             }
 
             continue;
@@ -129,7 +129,7 @@
 
         if (scf->log) {
             ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
-                          "\"%s\" matched", rule[i].re_name.data);
+                          "\"%s\" matches", rule[i].re_name.data);
         }
 
         uri.len = rule[i].size;
@@ -301,8 +301,10 @@
             }
         }
 
-        rule->msize++;
-        rule->msize *= 3;
+        if (rule->msize) {
+            rule->msize++;
+            rule->msize *= 3;
+        }
 
         if (cf->args->nelts > 3) {
             if (ngx_strcmp(value[3].data, "last") == 0) {
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 873267f..46c90f8 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -148,6 +148,13 @@
       offsetof(ngx_http_core_loc_conf_t, sendfile),
       NULL },
 
+    { ngx_string("tcp_nopush"),
+      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, tcp_nopush),
+      NULL },
+
     { ngx_string("send_timeout"),
       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
       ngx_conf_set_msec_slot,
@@ -505,6 +512,11 @@
         r->sendfile = 1;
     }
 
+    if (!clcf->tcp_nopush) {
+        /* disable TCP_NOPUSH/TCP_CORK use */
+        r->connection->tcp_nopush = -1;
+    }
+
     if (auto_redirect) {
         if (!(r->headers_out.location =
                    ngx_http_add_header(&r->headers_out, ngx_http_headers_out)))
@@ -1128,6 +1140,7 @@
 
     lcf->client_body_timeout = NGX_CONF_UNSET;
     lcf->sendfile = NGX_CONF_UNSET;
+    lcf->tcp_nopush = NGX_CONF_UNSET;
     lcf->send_timeout = NGX_CONF_UNSET;
     lcf->send_lowat = NGX_CONF_UNSET;
     lcf->discarded_buffer_size = NGX_CONF_UNSET;
@@ -1206,6 +1219,7 @@
     ngx_conf_merge_msec_value(conf->client_body_timeout,
                               prev->client_body_timeout, 10000);
     ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0);
+    ngx_conf_merge_value(conf->tcp_nopush, prev->tcp_nopush, 0);
     ngx_conf_merge_msec_value(conf->send_timeout, prev->send_timeout, 10000);
     ngx_conf_merge_size_value(conf->send_lowat, prev->send_lowat, 0);
     ngx_conf_merge_size_value(conf->discarded_buffer_size,
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 6673a18..78de144 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -122,6 +122,7 @@
 
     ngx_msec_t    client_body_timeout;     /* client_body_timeout */
     int           sendfile;                /* sendfile */
+    int           tcp_nopush;              /* tcp_nopush */
     ngx_msec_t    send_timeout;            /* send_timeout */
     ssize_t       send_lowat;              /* send_lowat */
     ssize_t       discarded_buffer_size;   /* discarded_buffer_size */
diff --git a/src/http/ngx_http_log_handler.h b/src/http/ngx_http_log_handler.h
index eb55f09..c67a01b 100644
--- a/src/http/ngx_http_log_handler.h
+++ b/src/http/ngx_http_log_handler.h
@@ -15,11 +15,6 @@
 
 #define NGX_HTTP_LOG_ARG         (u_int) -1
 
-/* STUB */
-#define NGX_INT32_LEN      sizeof("-2147483648") - 1
-#define NGX_TIME_T_LEN     sizeof("-2147483648") - 1
-#define NGX_OFF_T_LEN      sizeof("-9223372036854775808") - 1
-
 
 typedef struct {
     size_t               len;
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 6d11f4b..a8dfe0e 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -82,6 +82,7 @@
 
     rev = c->read;
     rev->event_handler = ngx_http_init_request;
+    rev->log_error = NGX_ERROR_INFO;
 
     if (rev->ready) {
         /* deferred accept, aio, iocp, epoll */
@@ -896,6 +897,17 @@
         ngx_del_timer(r->connection->write);
     }
 
+    if (r->connection->read->kq_eof) {
+#if (NGX_KQUEUE)
+        ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log,
+                       r->connection->read->kq_errno,
+                       "kevent reported about closed connection by client");
+#endif
+        ngx_http_close_request(r, 0);
+        ngx_http_close_connection(r->connection);
+        return;
+    }
+
     clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
 
     if (r->keepalive != 0 && clcf->keepalive_timeout > 0) {
@@ -1203,7 +1215,7 @@
 
     ctx->action = "keepalive";
 
-    if (c->tcp_nopush) {
+    if (c->tcp_nopush == 1) {
         if (ngx_tcp_push(c->fd) == NGX_ERROR) {
             ngx_log_error(NGX_LOG_CRIT, c->log, ngx_socket_errno,
                           ngx_tcp_push_n " failed");
@@ -1239,10 +1251,10 @@
      * so we ignore ECONNRESET here.
      */
 
-    rev->ignore_econnreset = 1;
+    rev->log_error = NGX_ERROR_IGNORE_ECONNRESET;
     ngx_set_socket_errno(0);
     n = ngx_recv(c, c->buffer->last, c->buffer->end - c->buffer->last);
-    rev->ignore_econnreset = 0;
+    rev->log_error = NGX_ERROR_INFO;
 
     if (n == NGX_AGAIN) {
         return;
@@ -1506,11 +1518,11 @@
         ngx_del_conn(c);
 
     } else {
-        if (c->read->active) {
+        if (c->read->active || c->read->disabled) {
             ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT);
         }
 
-        if (c->write->active) {
+        if (c->write->active || c->write->disabled) {
             ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT);
         }
     }