nginx-0.3.7-RELEASE import

    *) Feature: the "access_log" supports the "buffer=" parameter.

    *) Bugfix: nginx could not be built on platforms different from i386,
       amd64, sparc, and ppc; the bug had appeared in 0.3.2.
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 5a3593d..78ae2a7 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define NGINX_VER          "nginx/0.3.6"
+#define NGINX_VER          "nginx/0.3.7"
 
 #define NGINX_VAR          "NGINX"
 #define NGX_OLDPID_EXT     ".oldbin"
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index 78e61f8..acec130 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -11,6 +11,7 @@
 static ngx_int_t ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last);
 static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf);
 static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+static void ngx_conf_flush_files(ngx_cycle_t *cycle);
 
 
 static ngx_command_t  ngx_conf_commands[] = {
@@ -36,7 +37,7 @@
     NULL,                                  /* init process */
     NULL,                                  /* init thread */
     NULL,                                  /* exit thread */
-    NULL,                                  /* exit process */
+    ngx_conf_flush_files,                  /* exit process */
     NULL,                                  /* exit master */
     NGX_MODULE_V1_PADDING
 };
@@ -742,10 +743,44 @@
         file->name.data = NULL;
     }
 
+    file->buffer = NULL;
+
     return file;
 }
 
 
+static void
+ngx_conf_flush_files(ngx_cycle_t *cycle)
+{
+    ngx_uint_t        i;
+    ngx_list_part_t  *part;
+    ngx_open_file_t  *file;
+
+    ngx_log_debug0(NGX_LOG_DEBUG_CORE, cycle->log, 0, "flush files");
+
+    part = &cycle->open_files.part;
+    file = part->elts;
+
+    for (i = 0; /* void */ ; i++) {
+
+        if (i >= part->nelts) {
+            if (part->next == NULL) {
+                break;
+            }
+            part = part->next;
+            file = part->elts;
+            i = 0;
+        }
+
+        if (file[i].buffer == NULL || file[i].pos - file[i].buffer == 0) {
+            continue;
+        }
+
+        ngx_write_fd(file[i].fd, file[i].buffer, file[i].pos - file[i].buffer);
+    }
+}
+
+
 void ngx_cdecl
 ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err,
     char *fmt, ...)
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index 9f344e6..b09d8cc 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -34,6 +34,7 @@
 
 #define NGX_CONF_TAKE23      (NGX_CONF_TAKE2|NGX_CONF_TAKE3)
 
+#define NGX_CONF_TAKE123     (NGX_CONF_TAKE1|NGX_CONF_TAKE2|NGX_CONF_TAKE3)
 #define NGX_CONF_TAKE1234    (NGX_CONF_TAKE1|NGX_CONF_TAKE2|NGX_CONF_TAKE3   \
                               |NGX_CONF_TAKE4)
 
@@ -87,6 +88,11 @@
 struct ngx_open_file_s {
     ngx_fd_t              fd;
     ngx_str_t             name;
+
+    u_char               *buffer;
+    u_char               *pos;
+    u_char               *last;
+
 #if 0
     /* e.g. append mode, error_log */
     ngx_uint_t            flags;
@@ -121,10 +127,10 @@
 
     ngx_int_t           (*init_process)(ngx_cycle_t *cycle);
     ngx_int_t           (*init_thread)(ngx_cycle_t *cycle);
-    ngx_int_t           (*exit_thread)(ngx_cycle_t *cycle);
-    ngx_int_t           (*exit_process)(ngx_cycle_t *cycle);
+    void                (*exit_thread)(ngx_cycle_t *cycle);
+    void                (*exit_process)(ngx_cycle_t *cycle);
 
-    ngx_int_t           (*exit_master)(ngx_cycle_t *cycle);
+    void                (*exit_master)(ngx_cycle_t *cycle);
 
     uintptr_t             spare_hook0;
     uintptr_t             spare_hook1;
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index 58679ed..ab19611 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -724,6 +724,12 @@
             continue;
         }
 
+        if (file[i].buffer && file[i].pos - file[i].buffer != 0) {
+            ngx_write_fd(file[i].fd, file[i].buffer,
+                         file[i].pos - file[i].buffer);
+            file[i].pos = file[i].buffer;
+        }
+
         fd = ngx_open_file(file[i].name.data, NGX_FILE_RDWR,
                            NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
 
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index 905c8a1..444e943 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -8,7 +8,6 @@
 #include <ngx_core.h>
 
 
-static void ngx_log_write(ngx_log_t *log, u_char *errstr, size_t len);
 static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
 
 
@@ -152,42 +151,13 @@
         p = log->handler(log, p, last - p);
     }
 
-    ngx_log_write(log, errstr, p - errstr);
-}
-
-
-static void
-ngx_log_write(ngx_log_t *log, u_char *errstr, size_t len)
-{
-#if (NGX_WIN32)
-    u_long  written;
-
-    if (len >= NGX_MAX_ERROR_STR - 1) {
-        len = NGX_MAX_ERROR_STR - 2;
+    if (p > last - NGX_LINEFEED_SIZE) {
+        p = last - NGX_LINEFEED_SIZE;
     }
 
-    errstr[len++] = CR;
-    errstr[len++] = LF;
+    ngx_linefeed(p);
 
-    WriteFile(log->file->fd, errstr, len, &written, NULL);
-
-#if 0
-    if (WriteFile(log->file->fd, errstr, len, &written, NULL) == 0) {
-        ngx_message_box("nginx", MB_OK, ngx_errno, "WriteFile() failed");
-    }
-#endif
-
-#else
-
-    if (len == NGX_MAX_ERROR_STR) {
-        len--;
-    }
-
-    errstr[len++] = LF;
-
-    (void) write(log->file->fd, errstr, len);
-
-#endif
+    ngx_write_fd(log->file->fd, errstr, p - errstr);
 }