nginx-0.0.10-2004-09-05-23:54:02 import
diff --git a/src/core/ngx_array.h b/src/core/ngx_array.h
index f54517f..79a86e6 100644
--- a/src/core/ngx_array.h
+++ b/src/core/ngx_array.h
@@ -20,6 +20,23 @@
 void *ngx_push_array(ngx_array_t *a);
 
 
+ngx_inline static ngx_int_t ngx_init_array0(ngx_array_t *array, ngx_pool_t *pool,
+                                           ngx_uint_t n, size_t size)
+{
+    if (!(array->elts = ngx_palloc(pool, n * size))) {
+        return NGX_ERROR;
+    }
+
+    array->nelts = 0;
+    array->size = size;
+    array->nalloc = n;
+    array->pool = pool;
+
+    return NGX_OK;
+}
+
+
+
 #define ngx_init_array(a, p, n, s, rc)                                       \
     ngx_test_null(a.elts, ngx_palloc(p, n * s), rc);                         \
     a.nelts = 0; a.size = s; a.nalloc = n; a.pool = p;
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index d546fe6..ff23642 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -590,10 +590,6 @@
                 i = 0;
             }
 
-#if 0
-        file = cycle->open_files.elts;
-        for (i = 0; i < cycle->open_files.nelts; i++) {
-#endif
             if (name->len != file[i].name.len) {
                 continue;
             }
@@ -612,6 +608,9 @@
 
     if (name) {
         file->name = *name;
+    } else {
+        file->name.len = 0;
+        file->name.data = NULL;
     }
 
     return file;
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index 05a3a78..cc309e3 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -24,6 +24,8 @@
 static ngx_connection_t  dumb;
 /* STUB */
 
+static ngx_str_t  error_log = ngx_string(NGX_ERROR_LOG_PATH);
+
 
 ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
 {
@@ -79,31 +81,12 @@
         n = 20;
     }
 
-    cycle->open_files.part.elts = ngx_palloc(pool, n * sizeof(ngx_open_file_t));
-    if (cycle->open_files.part.elts == NULL) {
+    if (ngx_init_list(&cycle->open_files, pool, n, sizeof(ngx_open_file_t))
+                                                                  == NGX_ERROR)
+    {
         ngx_destroy_pool(pool);
         return NULL;
     }
-    cycle->open_files.part.nelts = 0;
-    cycle->open_files.part.next = NULL;
-    cycle->open_files.last = &cycle->open_files.part;
-    cycle->open_files.size = sizeof(ngx_open_file_t);
-    cycle->open_files.nalloc = n;
-    cycle->open_files.pool = pool;
-
-
-#if 0
-    n = old_cycle->open_files.nelts ? old_cycle->open_files.nelts : 20;
-    cycle->open_files.elts = ngx_pcalloc(pool, n * sizeof(ngx_open_file_t));
-    if (cycle->open_files.elts == NULL) {
-        ngx_destroy_pool(pool);
-        return NULL;
-    }
-    cycle->open_files.nelts = 0;
-    cycle->open_files.size = sizeof(ngx_open_file_t);
-    cycle->open_files.nalloc = n;
-    cycle->open_files.pool = pool;
-#endif
 
 
     if (!(cycle->new_log = ngx_log_create_errlog(cycle, NULL))) {
@@ -111,6 +94,8 @@
         return NULL;
     }
 
+    cycle->new_log->file->name = error_log;
+
 
     n = old_cycle->listening.nelts ? old_cycle->listening.nelts : 10;
     cycle->listening.elts = ngx_pcalloc(pool, n * sizeof(ngx_listening_t));
@@ -221,11 +206,6 @@
                 i = 0;
             }
 
-#if 0
-        file = cycle->open_files.elts;
-        for (i = 0; i < cycle->open_files.nelts; i++) {
-#endif
-
             if (file[i].name.data == NULL) {
                 continue;
             }
@@ -234,7 +214,9 @@
                                        NGX_FILE_RDWR,
                                        NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
 
+#if 0
             log->log_level = NGX_LOG_DEBUG_ALL;
+#endif
             ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0,
                            "log: %0X %d \"%s\"",
                            &file[i], file[i].fd, file[i].name.data);
@@ -270,6 +252,10 @@
     cycle->log = cycle->new_log;
     pool->log = cycle->new_log;
 
+    if (cycle->log->log_level == 0) {
+        cycle->log->log_level = NGX_LOG_ERR;
+    }
+
     if (!failed) {
         if (old_cycle->listening.nelts) {
             ls = old_cycle->listening.elts;
@@ -335,7 +321,7 @@
 
 #if !(WIN32)
 
-    if (!failed && !ngx_test_config) {
+    if (!failed && !ngx_test_config && cycle->log->file->fd != STDERR_FILENO) {
 
         ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0,
                        "dup2: %0X %d \"%s\"",
@@ -369,11 +355,6 @@
                 i = 0;
             }
 
-#if 0
-        file = cycle->open_files.elts;
-        for (i = 0; i < cycle->open_files.nelts; i++) {
-#endif
-
             if (file[i].fd == NGX_INVALID_FILE) {
                 continue;
             }
@@ -456,11 +437,6 @@
             i = 0;
         }
 
-#if 0
-    file = old_cycle->open_files.elts;
-    for (i = 0; i < old_cycle->open_files.nelts; i++) {
-#endif
-
         if (file[i].fd == NGX_INVALID_FILE) {
             continue;
         }
@@ -639,11 +615,6 @@
             i = 0;
         }
 
-#if 0
-    file = cycle->open_files.elts;
-    for (i = 0; i < cycle->open_files.nelts; i++) {
-#endif
-
         if (file[i].name.data == NULL) {
             continue;
         }
@@ -715,9 +686,11 @@
 
 #if !(WIN32)
 
-    if (dup2(cycle->log->file->fd, STDERR_FILENO) == -1) {
-        ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
-                      "dup2(STDERR) failed");
+    if (cycle->log->file->fd != STDERR_FILENO) {
+        if (dup2(cycle->log->file->fd, STDERR_FILENO) == -1) {
+            ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
+                          "dup2(STDERR) failed");
+        }
     }
 
 #endif
diff --git a/src/core/ngx_list.h b/src/core/ngx_list.h
index 4da8343..757564f 100644
--- a/src/core/ngx_list.h
+++ b/src/core/ngx_list.h
@@ -24,22 +24,47 @@
 } ngx_list_t;
 
 
-#define ngx_init_list(l, p, n, s, rc)                                        \
-    if (!(l.part.elts = ngx_palloc(p, n * s))) {                             \
-        return rc;                                                           \
-    }                                                                        \
-    l.part.nelts = 0; l.part.next = NULL;                                    \
-    l.last = &l.part; l.size = s; l.nalloc = n; l.pool = p;
+ngx_inline static ngx_int_t ngx_init_list(ngx_list_t *list, ngx_pool_t *pool,
+                                          ngx_uint_t n, size_t size)
+{
+    if (!(list->part.elts = ngx_palloc(pool, n * size))) {
+        return NGX_ERROR;
+    }
+
+    list->part.nelts = 0;
+    list->part.next = NULL;
+    list->last = &list->part;
+    list->size = size;
+    list->nalloc = n;
+    list->pool = pool;
+
+    return NGX_OK;
+}
 
 
-#define ngx_iterate_list(p, i)                                               \
-            for ( ;; i++) {                                                  \
-                if (i >= p->nelts) {                                         \
-                    if (p->next == NULL) {                                   \
-                        break;                                               \
-                    }                                                        \
-                    p = p->next; i = 0;                                      \
-                }
+/*
+ *
+ *  the iteration through the list:
+ *
+ *  part = &list.part;
+ *  data = part->elts;
+ *
+ *  for (i = 0 ;; i++) {
+ *
+ *      if (i >= part->nelts) {
+ *          if (part->next == NULL) {
+ *              break;
+ *          }
+ *
+ *          part = part->next;
+ *          data = part->elts;
+ *          i = 0;
+ *      }
+ *
+ *      ...  data[i] ...
+ *
+ *  }
+ */
 
 
 void *ngx_push_list(ngx_list_t *list);
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index 7638b6a..a3f6e77 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -37,8 +37,8 @@
 };
 
 
-static ngx_open_file_t  ngx_stderr;
 static ngx_log_t        ngx_log;
+static ngx_open_file_t  ngx_stderr;
 
 
 static const char *err_levels[] = {
@@ -296,8 +296,13 @@
         name = NULL;
     }
 
-    ngx_test_null(log, ngx_pcalloc(cycle->pool, sizeof(ngx_log_t)), NULL);
-    ngx_test_null(log->file, ngx_conf_open_file(cycle, name), NULL);
+    if (!(log = ngx_pcalloc(cycle->pool, sizeof(ngx_log_t)))) {
+        return NULL;
+    }
+
+    if (!(log->file = ngx_conf_open_file(cycle, name))) {
+        return NULL;
+    }
 
     return log;
 }
@@ -363,7 +368,9 @@
     value = cf->args->elts;
 
     if (value[1].len == 6 && ngx_strcmp(value[1].data, "stderr") == 0) {
-        cf->cycle->new_log->file = &ngx_stderr;
+        cf->cycle->new_log->file->fd = ngx_stderr.fd;
+        cf->cycle->new_log->file->name.len = 0;
+        cf->cycle->new_log->file->name.data = NULL;
 
     } else {
         cf->cycle->new_log->file->name = value[1];