changeset 95:b48066122884

nginx-0.0.1-2003-05-23-15:53:01 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 23 May 2003 11:53:01 +0000
parents 8220378432a8
children a23d010f356d
files src/event/modules/ngx_aio_module.c src/event/modules/ngx_kqueue_module.c src/http/ngx_http.c src/http/ngx_http_core_module.c src/http/ngx_http_core_module.h src/http/ngx_http_event.c src/http/ngx_http_output_filter.c src/os/unix/ngx_aio_write_chain.c src/os/unix/ngx_errno.h src/os/unix/ngx_time.c src/os/win32/ngx_stat.h
diffstat 11 files changed, 144 insertions(+), 169 deletions(-) [+]
line wrap: on
line diff
--- a/src/event/modules/ngx_aio_module.c
+++ b/src/event/modules/ngx_aio_module.c
@@ -81,7 +81,7 @@ static void ngx_aio_done(ngx_log_t *log)
 }
 
 
-/* The event adding and deleteing are needed for the listening sockets */
+/* The event adding and deleting are needed for the listening sockets */
 
 static int ngx_aio_add_event(ngx_event_t *ev, int event, u_int flags)
 {
@@ -99,49 +99,38 @@ static int ngx_aio_del_connection(ngx_co
 {
     int  rc;
 
-    if (c->read->active || c->write->active) {
-        rc = aio_cancel(c->fd, NULL);
-        if (rc == -1) {
-            ngx_log_error(NGX_LOG_CRIT, c->log, ngx_errno,
-                          "aio_cancel() failed");
-            return NGX_ERROR;
-        }
+    if (c->read->active == 0 && c->write->active == 0) {
+        return NGX_OK;
+    }
 
-        ngx_log_debug(c->log, "aio_cancel: %d" _ rc);
+    rc = aio_cancel(c->fd, NULL);
 
-#if 0
-        rc = aio_error(&c->read->aiocb);
-        if (rc == -1) {
-            ngx_log_error(NGX_LOG_CRIT, c->log, ngx_errno,
-                          "aio_error() failed");
-            return NGX_ERROR;
-        }
+    ngx_log_debug(c->log, "aio_cancel: %d" _ rc);
 
-        ngx_log_debug(c->log, "aio_error: %d" _ rc);
-#endif
+    if (rc == AIO_CANCELED) {
+        c->read->active = c->write->active = 0;
+        return NGX_OK;
     }
 
-#if 0
-    if (c->write->active) {
-        rc = aio_cancel(c->fd, &c->write->aiocb);
-        if (rc == -1) {
-            ngx_log_error(NGX_LOG_CRIT, c->log, ngx_errno,
-                          "aio_cancel() failed");
-            return NGX_ERROR;
-        }
-
-        ngx_log_debug(c->log, "aio_cancel: %d" _ rc);
+    if (rc == AIO_ALLDONE) {
+        c->read->active = c->write->active = 0;
+        ngx_log_error(NGX_LOG_ALERT, c->log, 0,
+                      "aio_cancel() returned AIO_ALLDONE");
+        return NGX_OK;
+    }
 
-        rc = aio_error(&c->read->aiocb);
-        if (rc == -1) {
-            ngx_log_error(NGX_LOG_CRIT, c->log, ngx_errno,
-                          "aio_error() failed");
-            return NGX_ERROR;
-        }
+    if (rc == -1) {
+        ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
+                      "aio_cancel() failed");
+        return NGX_ERROR;
+    }
 
-        ngx_log_debug(c->log, "aio_error: %d" _ rc);
+    if (rc == AIO_NOTCANCELED) {
+        ngx_log_error(NGX_LOG_ALERT, c->log, 0,
+                      "aio_cancel() returned AIO_NOTCANCELED");
+
+        return NGX_ERROR;
     }
-#endif
 
     return NGX_OK;
 }
@@ -152,7 +141,7 @@ static int ngx_aio_process_events(ngx_lo
     return ngx_kqueue_module_ctx.actions.process(log);
 }
 
-#endif
+#endif /* HAVE_KQUEUE */
 
 
 #if 0
--- a/src/event/modules/ngx_kqueue_module.c
+++ b/src/event/modules/ngx_kqueue_module.c
@@ -57,7 +57,7 @@ ngx_event_module_t  ngx_kqueue_module_ct
     ngx_kqueue_create_conf,                /* create configuration */
     ngx_kqueue_init_conf,                  /* init configuration */
 
-    { 
+    {
         ngx_kqueue_add_event,              /* add an event */
         ngx_kqueue_del_event,              /* delete an event */
         ngx_kqueue_add_event,              /* enable an event */
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -462,12 +462,12 @@ static char *ngx_http_block(ngx_conf_t *
             ls->addr = offsetof(struct sockaddr_in, sin_addr);
             ls->addr_text_max_len = INET_ADDRSTRLEN;
             ls->backlog = -1;
-            ls->post_accept_timeout = cmcf->post_accept_timeout;
             ls->nonblocking = 1;
 
             ls->handler = ngx_http_init_connection;
             ls->log = cf->log;
             ls->pool_size = cmcf->connection_pool_size;
+            ls->post_accept_timeout = cmcf->post_accept_timeout;
             ls->ctx = ctx;
 
             if (in_port[p].addrs.nelts > 1) {
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -49,13 +49,6 @@ static ngx_command_t  ngx_http_core_comm
      0,
      NULL,},
 
-    {ngx_string("post_accept_timeout"),
-     NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
-     ngx_conf_set_msec_slot,
-     NGX_HTTP_MAIN_CONF_OFFSET,
-     offsetof(ngx_http_core_main_conf_t, post_accept_timeout),
-     NULL},
-
     {ngx_string("connection_pool_size"),
      NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
      ngx_conf_set_size_slot,
@@ -63,32 +56,39 @@ static ngx_command_t  ngx_http_core_comm
      offsetof(ngx_http_core_main_conf_t, connection_pool_size),
      NULL},
 
-    {ngx_string("request_pool_size"),
-     NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
-     ngx_conf_set_size_slot,
-     NGX_HTTP_MAIN_CONF_OFFSET,
-     offsetof(ngx_http_core_main_conf_t, request_pool_size),
-     NULL},
-
-    {ngx_string("client_header_timeout"),
+    {ngx_string("post_accept_timeout"),
      NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
      ngx_conf_set_msec_slot,
      NGX_HTTP_MAIN_CONF_OFFSET,
-     offsetof(ngx_http_core_main_conf_t, client_header_timeout),
+     offsetof(ngx_http_core_main_conf_t, post_accept_timeout),
+     NULL},
+
+    {ngx_string("request_pool_size"),
+     NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
+     ngx_conf_set_size_slot,
+     NGX_HTTP_SRV_CONF_OFFSET,
+     offsetof(ngx_http_core_srv_conf_t, request_pool_size),
+     NULL},
+
+    {ngx_string("client_header_timeout"),
+     NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
+     ngx_conf_set_msec_slot,
+     NGX_HTTP_SRV_CONF_OFFSET,
+     offsetof(ngx_http_core_srv_conf_t, client_header_timeout),
      NULL},
 
     {ngx_string("client_header_buffer_size"),
-     NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
+     NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
      ngx_conf_set_size_slot,
-     NGX_HTTP_MAIN_CONF_OFFSET,
-     offsetof(ngx_http_core_main_conf_t, client_header_buffer_size),
+     NGX_HTTP_SRV_CONF_OFFSET,
+     offsetof(ngx_http_core_srv_conf_t, client_header_buffer_size),
      NULL},
 
     {ngx_string("large_client_header"),
-     NGX_HTTP_MAIN_CONF|NGX_CONF_FLAG,
+     NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
      ngx_conf_set_flag_slot,
-     NGX_HTTP_MAIN_CONF_OFFSET,
-     offsetof(ngx_http_core_main_conf_t, large_client_header),
+     NGX_HTTP_SRV_CONF_OFFSET,
+     offsetof(ngx_http_core_srv_conf_t, large_client_header),
      NULL},
 
     {ngx_string("location"),
@@ -814,12 +814,8 @@ static void *ngx_http_core_create_main_c
                   ngx_palloc(pool, sizeof(ngx_http_core_main_conf_t)), 
                   NGX_CONF_ERROR);
 
+    cmcf->connection_pool_size = NGX_CONF_UNSET;
     cmcf->post_accept_timeout = NGX_CONF_UNSET;
-    cmcf->connection_pool_size = NGX_CONF_UNSET;
-    cmcf->request_pool_size = NGX_CONF_UNSET;
-    cmcf->client_header_timeout = NGX_CONF_UNSET;
-    cmcf->client_header_buffer_size = NGX_CONF_UNSET;
-    cmcf->large_client_header = NGX_CONF_UNSET;
 
     ngx_init_array(cmcf->servers, pool, 5, sizeof(ngx_http_core_srv_conf_t *),
                    NGX_CONF_ERROR);
@@ -832,12 +828,8 @@ static char *ngx_http_core_init_main_con
 {
     ngx_http_core_main_conf_t *cmcf = (ngx_http_core_main_conf_t *) conf;
 
+    ngx_conf_init_size_value(cmcf->connection_pool_size, 16384);
     ngx_conf_init_msec_value(cmcf->post_accept_timeout, 30000);
-    ngx_conf_init_size_value(cmcf->connection_pool_size, 16384);
-    ngx_conf_init_size_value(cmcf->request_pool_size, 16384);
-    ngx_conf_init_msec_value(cmcf->client_header_timeout, 60000);
-    ngx_conf_init_size_value(cmcf->client_header_buffer_size, 1024);
-    ngx_conf_init_value(cmcf->large_client_header, 1);
 
     return NGX_CONF_OK;
 }
@@ -857,6 +849,11 @@ static void *ngx_http_core_create_srv_co
     ngx_init_array(cscf->server_names, pool, 5, sizeof(ngx_http_server_name_t),
                    NGX_CONF_ERROR);
 
+    cscf->request_pool_size = NGX_CONF_UNSET;
+    cscf->client_header_timeout = NGX_CONF_UNSET;
+    cscf->client_header_buffer_size = NGX_CONF_UNSET;
+    cscf->large_client_header = NGX_CONF_UNSET;
+
     return cscf;
 }
 
@@ -895,6 +892,15 @@ static char *ngx_http_core_merge_srv_con
         n->core_srv_conf = conf;
     }
 
+    ngx_conf_merge_size_value(conf->request_pool_size,
+                              prev->request_pool_size, 16384);
+    ngx_conf_merge_msec_value(conf->client_header_timeout,
+                              prev->client_header_timeout, 60000);
+    ngx_conf_merge_size_value(conf->client_header_buffer_size,
+                              prev->client_header_buffer_size, 1024);
+    ngx_conf_merge_value(conf->large_client_header,
+                         prev->large_client_header, 1);
+
     return NGX_CONF_OK;
 }
 
@@ -984,17 +990,15 @@ static char *ngx_http_core_merge_loc_con
     }
 
     ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0);
-
     ngx_conf_merge_msec_value(conf->send_timeout, prev->send_timeout, 10000);
-
     ngx_conf_merge_size_value(conf->discarded_buffer_size,
                               prev->discarded_buffer_size, 1500);
-    ngx_conf_merge_msec_value(conf->keepalive_timeout, prev->keepalive_timeout,
-                              70000);
-    ngx_conf_merge_msec_value(conf->lingering_time, prev->lingering_time,
-                              30000);
-    ngx_conf_merge_msec_value(conf->lingering_timeout, prev->lingering_timeout,
-                              5000);
+    ngx_conf_merge_msec_value(conf->keepalive_timeout,
+                              prev->keepalive_timeout, 70000);
+    ngx_conf_merge_msec_value(conf->lingering_time,
+                              prev->lingering_time, 30000);
+    ngx_conf_merge_msec_value(conf->lingering_timeout,
+                              prev->lingering_timeout, 5000);
 
     return NGX_CONF_OK;
 }
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -18,13 +18,8 @@ typedef struct {
 
 
 typedef struct {
+    int          connection_pool_size;
     int          post_accept_timeout;
-    int          connection_pool_size;
-    int          request_pool_size;
-    int          client_header_timeout;
-    int          client_header_buffer_size;
-    int          large_client_header;
-    int          url_in_error_log;
 
     ngx_array_t  servers;      /* array of ngx_http_core_srv_conf_t */
 } ngx_http_core_main_conf_t;
@@ -40,6 +35,11 @@ typedef struct {
                                   array of ngx_http_server_name_t */
 
     ngx_http_conf_ctx_t *ctx;  /* server ctx */
+
+    size_t       request_pool_size;
+    ngx_msec_t   client_header_timeout;
+    size_t       client_header_buffer_size;
+    int          large_client_header;
 } ngx_http_core_srv_conf_t;
 
 
--- a/src/http/ngx_http_event.c
+++ b/src/http/ngx_http_event.c
@@ -58,9 +58,9 @@ static char *header_errors[] = {
 static ngx_http_header_t headers_in[] = {
     { ngx_string("Host"), offsetof(ngx_http_headers_in_t, host) },
     { ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection) },
-    { ngx_string("If-Modified-Since"), 
+    { ngx_string("If-Modified-Since"),
                          offsetof(ngx_http_headers_in_t, if_modified_since) },
-    { ngx_string("Content-Length"), 
+    { ngx_string("Content-Length"),
                             offsetof(ngx_http_headers_in_t, content_length) },
 
 #if 0
@@ -75,9 +75,10 @@ static ngx_http_header_t headers_in[] = 
 
 void ngx_http_init_connection(ngx_connection_t *c)
 {
-    int                  event;
-    ngx_event_t         *rev;
-    ngx_http_log_ctx_t  *lcx;
+    int                   event;
+    ngx_event_t          *rev;
+    ngx_http_log_ctx_t   *lcx;
+    ngx_http_conf_ctx_t  *ctx;
 
     c->addr_text.data = ngx_palloc(c->pool, c->addr_text_max_len);
     if (c->addr_text.data == NULL) {
@@ -138,19 +139,20 @@ void ngx_http_init_connection(ngx_connec
 
 static void ngx_http_init_request(ngx_event_t *rev)
 {
-    ngx_connection_t           *c;
-    ngx_http_request_t         *r;
-    ngx_http_conf_ctx_t        *ctx;
-    ngx_http_core_main_conf_t  *cmcf;
+    ngx_connection_t          *c;
+    ngx_http_request_t        *r;
+    ngx_http_conf_ctx_t       *ctx;
+    ngx_http_core_srv_conf_t  *cscf;
 
     c = rev->data;
     ctx = c->ctx;
 
-    cmcf = ngx_http_get_module_main_conf(ctx, ngx_http_core_module_ctx);
+    cscf = ngx_http_get_module_srv_conf(ctx, ngx_http_core_module_ctx);
+    cscf = ngx_http_get_module_srv_conf(cscf->ctx, ngx_http_core_module_ctx);
 
     if (c->buffer == NULL) {
         c->buffer = ngx_create_temp_hunk(c->pool,
-                                         cmcf->client_header_buffer_size,
+                                         cscf->client_header_buffer_size,
                                          0, 0);
         if (c->buffer == NULL) {
             ngx_http_close_connection(c);
@@ -164,7 +166,7 @@ static void ngx_http_init_request(ngx_ev
         return;
     }
 
-    r->pool = ngx_create_pool(cmcf->request_pool_size, c->log);
+    r->pool = ngx_create_pool(cscf->request_pool_size, c->log);
     if (r->pool == NULL) {
         ngx_http_close_connection(c);
         return;
@@ -207,12 +209,12 @@ static void ngx_http_init_request(ngx_ev
 
 static void ngx_http_process_request_line(ngx_event_t *rev)
 {
-    int                         rc, offset;
-    ssize_t                     n;
-    ngx_connection_t           *c;
-    ngx_http_request_t         *r;
-    ngx_http_log_ctx_t         *lcx;
-    ngx_http_core_main_conf_t  *cmcf;
+    int                        rc, offset;
+    ssize_t                    n;
+    ngx_connection_t          *c;
+    ngx_http_request_t        *r;
+    ngx_http_log_ctx_t        *lcx;
+    ngx_http_core_srv_conf_t  *cscf;
 
     c = rev->data;
     r = c->data;
@@ -237,10 +239,10 @@ static void ngx_http_process_request_lin
 
         /* the request line has been parsed successfully */
 
-        cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module_ctx);
+        cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module_ctx);
 
         if (r->http_version >= NGX_HTTP_VERSION_10
-            && cmcf->large_client_header == 0
+            && cscf->large_client_header == 0
             && r->header_in->pos == r->header_in->end)
         {
             /* no space for "\r\n" at the end of the header */
@@ -289,7 +291,7 @@ static void ngx_http_process_request_lin
         /* if the large client headers are enabled then
            we need to copy a request line */
 
-        if (cmcf->large_client_header) {
+        if (cscf->large_client_header) {
 
             r->request_line.data = ngx_palloc(r->pool, r->request_line.len + 1);
             if (r->request_line.data == NULL) {
@@ -367,7 +369,7 @@ static void ngx_http_process_request_lin
         lcx->url = r->unparsed_uri.data;
         r->headers_in.headers = ngx_create_table(r->pool, 10);
 
-        if (cmcf->large_client_header
+        if (cscf->large_client_header
             && r->header_in->pos == r->header_in->last)
         {
             r->header_in->pos = r->header_in->last = r->header_in->start;
@@ -398,9 +400,9 @@ static void ngx_http_process_request_lin
            are enabled otherwise a request line had been already copied
            to the start of the r->header_in hunk in ngx_http_set_keepalive() */
 
-        cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module_ctx);
+        cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module_ctx);
 
-        if (cmcf->large_client_header) {
+        if (cscf->large_client_header) {
             offset = r->request_start - r->header_in->start;
 
             if (offset == 0) {
@@ -438,14 +440,14 @@ static void ngx_http_process_request_lin
 
 static void ngx_http_process_request_headers(ngx_event_t *rev)
 {
-    int                         rc, i, offset;
-    size_t                      len;
-    ssize_t                     n;
-    ngx_table_elt_t            *h;
-    ngx_connection_t           *c;
-    ngx_http_request_t         *r;
-    ngx_http_log_ctx_t         *ctx;
-    ngx_http_core_main_conf_t  *cmcf;
+    int                        rc, i, offset;
+    size_t                     len;
+    ssize_t                    n;
+    ngx_table_elt_t           *h;
+    ngx_connection_t          *c;
+    ngx_http_request_t        *r;
+    ngx_http_log_ctx_t        *ctx;
+    ngx_http_core_srv_conf_t  *cscf;
 
     c = rev->data;
     r = c->data;
@@ -488,9 +490,9 @@ static void ngx_http_process_request_hea
             /* if the large client headers are enabled then
                we need to copy the header name and value */
 
-            cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module_ctx);
+            cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module_ctx);
 
-            if (cmcf->large_client_header) {
+            if (cscf->large_client_header) {
                 h->key.data = ngx_palloc(r->pool,
                                          h->key.len + 1 + h->value.len + 1);
                 if (h->key.data == NULL) {
@@ -524,7 +526,7 @@ static void ngx_http_process_request_hea
             ngx_log_debug(r->connection->log, "HTTP header: '%s: %s'" _
                           h->key.data _ h->value.data);
 
-            if (cmcf->large_client_header
+            if (cscf->large_client_header
                 && r->header_in->pos == r->header_in->last)
             {
                 r->header_in->pos = r->header_in->last = r->header_in->start;
@@ -593,9 +595,9 @@ static void ngx_http_process_request_hea
             /* if the large client headers are enabled then
                 we need to compact r->header_in hunk */
 
-            cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module_ctx);
+            cscf = ngx_http_get_module_main_conf(r, ngx_http_core_module_ctx);
 
-            if (cmcf->large_client_header) {
+            if (cscf->large_client_header) {
                 offset = r->header_name_start - r->header_in->start;
 
                 if (offset == 0) {
@@ -627,10 +629,10 @@ static void ngx_http_process_request_hea
 
 static ssize_t ngx_http_read_request_header(ngx_http_request_t *r)
 {
-    int                         event;
-    ssize_t                     n;
-    ngx_event_t                *rev;
-    ngx_http_core_main_conf_t  *cmcf;
+    int                        event;
+    ssize_t                    n;
+    ngx_event_t               *rev;
+    ngx_http_core_srv_conf_t  *cscf;
 
     n = r->header_in->last - r->header_in->pos;
 
@@ -651,9 +653,9 @@ static ssize_t ngx_http_read_request_hea
                 rev->timer_set = 1;
             }
 
-            cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module_ctx);
+            cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module_ctx);
 
-            ngx_add_timer(rev, cmcf->client_header_timeout);
+            ngx_add_timer(rev, cscf->client_header_timeout);
             r->header_timeout_set = 1;
         }
 
@@ -913,7 +915,7 @@ int ngx_http_discard_body(ngx_http_reque
                 return NGX_OK;
             }
         }
- 
+
         rev->event_handler = ngx_http_read_discarded_body_event;
 
         if (rev->blocked) {
@@ -991,13 +993,13 @@ static int ngx_http_read_discarded_body(
 
 static void ngx_http_set_keepalive(ngx_http_request_t *r)
 {
-    int                         len, blocked;
-    ngx_hunk_t                 *h;
-    ngx_event_t                *rev, *wev;
-    ngx_connection_t           *c;
-    ngx_http_log_ctx_t         *ctx;
-    ngx_http_core_main_conf_t  *cmcf;
-    ngx_http_core_loc_conf_t   *clcf;
+    int                        len, blocked;
+    ngx_hunk_t                *h;
+    ngx_event_t               *rev, *wev;
+    ngx_connection_t          *c;
+    ngx_http_log_ctx_t        *ctx;
+    ngx_http_core_srv_conf_t  *cscf;
+    ngx_http_core_loc_conf_t  *clcf;
 
     c = (ngx_connection_t *) r->connection;
     rev = c->read;
@@ -1043,10 +1045,10 @@ static void ngx_http_set_keepalive(ngx_h
            This copy should be rare because clients that support
            pipelined requests (Mozilla 1.x, Opera 6.x) are still rare */
 
-        cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module_ctx);
+        cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module_ctx);
 
-        if (!cmcf->large_client_header) {
-            len = h->last - h->pos; 
+        if (!cscf->large_client_header) {
+            len = h->last - h->pos;
             ngx_memcpy(h->start, h->pos, len);
             h->pos = h->start;
             h->last = h->start + len;
--- a/src/http/ngx_http_output_filter.c
+++ b/src/http/ngx_http_output_filter.c
@@ -150,8 +150,6 @@ int ngx_http_output_filter(ngx_http_requ
             return rc;
         }
 
-ngx_log_debug(r->connection->log, "HERE");
-
         /* NGX_OK */
         /* set our hunk free */
         ctx->hunk->pos = ctx->hunk->last = ctx->hunk->start;
--- a/src/os/unix/ngx_aio_write_chain.c
+++ b/src/os/unix/ngx_aio_write_chain.c
@@ -17,9 +17,6 @@ ngx_chain_t *ngx_aio_write_chain(ngx_con
     ce = in;
 
     while (ce) {
-
-ngx_log_debug(c->log, "aio_write ce: %x" _ ce->hunk->pos);
-
         buf = prev = ce->hunk->pos;
         size = 0;
 
@@ -32,7 +29,9 @@ ngx_log_debug(c->log, "aio_write ce: %x"
 
         rc = ngx_aio_write(c, buf, size);
 
-ngx_log_debug(c->log, "aio_write rc: %d" _ rc);
+#if (NGX_DEBUG_WRITE_CHAIN)
+        ngx_log_debug(c->log, "aio_write rc: %d" _ rc);
+#endif
 
         if (rc > 0) {
             sent += rc;
@@ -52,31 +51,14 @@ ngx_log_debug(c->log, "aio_write rc: %d"
 
     for (ce = in; ce; ce = ce->next) {
 
-#if (NGX_DEBUG_WRITE_CHAIN)
-        ngx_log_debug(c->log, "write chain: %x %qx %qd" _
-                      ce->hunk->type _
-                      ce->hunk->file_pos _
-                      ce->hunk->file_last - ce->hunk->file_pos);
-#endif
+        if (sent >= ce->hunk->last - ce->hunk->pos) {
+            sent -= ce->hunk->last - ce->hunk->pos;
+            ce->hunk->pos = ce->hunk->last;
 
-        if (sent >= ce->hunk->file_last - ce->hunk->file_pos) {
-            sent -= ce->hunk->file_last - ce->hunk->file_pos;
-            ce->hunk->file_pos = ce->hunk->file_last;
-
-#if (NGX_DEBUG_WRITE_CHAIN)
-            ngx_log_debug(c->log, "write chain done: %qx %qd" _
-                          ce->hunk->file_pos _ sent);
-#endif
             continue;
         }
 
-        ce->hunk->file_pos += sent;
-
-#if (NGX_DEBUG_WRITE_CHAIN)
-        ngx_log_debug(c->log, "write chain rest: %qx %qd" _
-                      ce->hunk->file_pos _
-                      ce->hunk->file_last - ce->hunk->file_pos);
-#endif
+        ce->hunk->pos += sent;
 
         break;
     }
--- a/src/os/unix/ngx_errno.h
+++ b/src/os/unix/ngx_errno.h
@@ -10,7 +10,7 @@ typedef int               ngx_err_t;
 #define NGX_ENOENT        ENOENT
 #define NGX_EINTR         EINTR
 #define NGX_EACCES        EACCES
-#define NGX_EEXIST        EEXIST 
+#define NGX_EEXIST        EEXIST
 #define NGX_ENOTDIR       ENOTDIR
 #define NGX_EAGAIN        EWOULDBLOCK
 #define NGX_EINPROGRESS   EINPROGRESS
--- a/src/os/unix/ngx_time.c
+++ b/src/os/unix/ngx_time.c
@@ -28,7 +28,7 @@ typedef struct {
     time_t sec;
     tm;
     http_time_len;
-    http_time[n];    
+    http_time[n];
 };
 
 volatile *ngx_time_p;
--- a/src/os/win32/ngx_stat.h
+++ b/src/os/win32/ngx_stat.h
@@ -14,7 +14,7 @@ typedef BY_HANDLE_FILE_INFORMATION  ngx_
 
 #define ngx_file_type_n          "GetFileAttributes"
 
-#define ngx_is_dir(fi)          (fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 
+#define ngx_is_dir(fi)          (fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
 
 #define ngx_stat_n               "GetFileAttributes"