nginx-0.0.1-2003-07-04-19:10:33 import
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 89dd6f0..fb34578 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -15,7 +15,7 @@
 ngx_os_io_t  ngx_io;
 
 
-ngx_cycle_t  *cycle;
+ngx_cycle_t  ngx_cycle;
 
 int     ngx_max_module;
 
@@ -30,7 +30,7 @@
 {
     int           i;
     ngx_log_t    *log;
-    ngx_cycle_t  *new_cycle;
+    ngx_cycle_t  *cycle;
 
     /* TODO */ ngx_max_sockets = -1;
 
@@ -50,23 +50,27 @@
         return 1;
     }
 
+    ngx_cycle = *cycle;
+
     /* daemon */
 
     /* life cycle */
 
     for ( ;; ) {
-        /* STUB */ cycle->log->file->fd = log->file->fd;
-        /* STUB */ cycle->log->log_level = NGX_LOG_DEBUG;
-
-        /* STUB */
-        ngx_io = ngx_os_io;
+        /* STUB */ ngx_cycle.log->log_level = NGX_LOG_DEBUG;
 
         /* forks */
 
         ngx_init_temp_number();
 
-        /* STUB */
-        ngx_pre_thread(&cycle->listening, cycle->pool, cycle->log);
+        for (i = 0; ngx_modules[i]; i++) {
+            if (ngx_modules[i]->init_child) {
+                if (ngx_modules[i]->init_child(&ngx_cycle) == NGX_ERROR) {
+                    /* fatal */
+                    exit(1);
+                }
+            }
+        }
 
         /* threads */
 
@@ -76,27 +80,29 @@
         for ( ;; ) {
 
             for ( ;; ) {
-                ngx_log_debug(cycle->log, "worker cycle");
+                ngx_log_debug(ngx_cycle.log, "worker cycle");
 
-                ngx_process_events(cycle->log);
+                ngx_process_events(ngx_cycle.log);
 
                 if (rotate) {
-                    ngx_log_debug(cycle->log, "rotate");
+                    ngx_log_debug(ngx_cycle.log, "rotate");
                 }
 
                 if (restart) {
-                    ngx_log_debug(cycle->log, "restart");
+                    ngx_log_debug(ngx_cycle.log, "restart");
                     break;
                 }
 
             }
 
-            new_cycle = ngx_init_cycle(cycle, cycle->log);
-            if (new_cycle == NULL) {
+            cycle = ngx_init_cycle(&ngx_cycle, ngx_cycle.log);
+            if (cycle == NULL) {
                 continue;
             }
 
-            cycle = new_cycle;
+ngx_log_debug(ngx_cycle.log, "OPEN: %d" _ cycle->log->file->fd);
+            ngx_cycle = *cycle;
+ngx_log_debug(ngx_cycle.log, "OPEN: %d" _ ngx_cycle.log->file->fd);
             break;
         }
     }
@@ -187,38 +193,32 @@
 
     failed = 0;
 
-    for (i = 0; ngx_modules[i]; i++) {
-        if (ngx_modules[i]->init_module) {
-            if (ngx_modules[i]->init_module(cycle, log) == NGX_ERROR)
-            {
-                failed = 1;
-                break;
-            }
+ngx_log_debug(log, "OPEN: %d" _ cycle->log->file->fd);
+
+    file = cycle->open_files.elts;
+    for (i = 0; i < cycle->open_files.nelts; i++) {
+        if (file->name.data == NULL) {
+            continue;
         }
+
+        file->fd = ngx_open_file(file->name.data,
+                                 NGX_FILE_RDWR,
+                                 NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
+
+        if (file->fd == NGX_INVALID_FILE) {
+            ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
+                          ngx_open_file_n " \"%s\" failed",
+                          file->name.data);
+            failed = 1;
+            break;
+        }
+
+        /* TODO: Win32 append */
     }
 
-    if (!failed) {
-        file = cycle->open_files.elts;
-        for (i = 0; i < cycle->open_files.nelts; i++) {
-            if (file->name.data == NULL) {
-                continue;
-            }
-
-            file->fd = ngx_open_file(file->name.data,
-                                     NGX_FILE_RDWR,
-                                     NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
-
-            if (file->fd == NGX_INVALID_FILE) {
-                ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
-                              ngx_open_file_n " \"%s\" failed",
-                              file->name.data);
-                failed = 1;
-                break;
-            }
-
-            /* TODO: Win32 append */
-        }
-    }
+ngx_log_debug(log, "OPEN: %d" _ cycle->log->file->fd);
+        /* STUB */ cycle->log->log_level = NGX_LOG_DEBUG;
+ngx_log_debug(cycle->log, "TEST");
 
     if (!failed) {
         if (old_cycle) {
@@ -254,12 +254,6 @@
 
         /* rollback the new cycle configuration */
 
-        for (i = 0; ngx_modules[i]; i++) {
-            if (ngx_modules[i]->rollback_module) {
-                ngx_modules[i]->rollback_module(cycle, log);
-            }
-        }
-
         file = cycle->open_files.elts;
         for (i = 0; i < cycle->open_files.nelts; i++) {
             if (file->fd == NGX_INVALID_FILE) {
@@ -292,14 +286,17 @@
 
     /* commit the new cycle configuration */
 
+    pool->log = cycle->log;
+
     for (i = 0; ngx_modules[i]; i++) {
-        if (ngx_modules[i]->commit_module) {
-            ngx_modules[i]->commit_module(cycle, log);
+        if (ngx_modules[i]->init_module) {
+            if (ngx_modules[i]->init_module(cycle) == NGX_ERROR) {
+                /* fatal */
+                exit(1);
+            }
         }
     }
 
-    pool->log = cycle->log;
-
     if (old_cycle == NULL) {
         return cycle;
     }
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index 932f5bf..7e0010d 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -79,9 +79,8 @@
     void           *ctx;
     ngx_command_t  *commands;
     int             type;
-    int           (*init_module)(ngx_cycle_t *cycle, ngx_log_t *log);
-    int           (*commit_module)(ngx_cycle_t *cycle, ngx_log_t *log);
-    int           (*rollback_module)(ngx_cycle_t *cycle, ngx_log_t *log);
+    int           (*init_module)(ngx_cycle_t *cycle);
+    int           (*init_child)(ngx_cycle_t *cycle);
 };
 
 
@@ -114,7 +113,7 @@
 };
 
 
-#define ngx_get_conf(module)  ngx_conf_ctx[module.index]
+#define ngx_get_conf(conf_ctx, module)  conf_ctx[module.index]
 
 
 #define ngx_conf_init_value(conf, default)                                   \
@@ -179,7 +178,7 @@
 
 
 extern ngx_module_t     *ngx_modules[];
-extern void          ****ngx_conf_ctx;
+extern ngx_cycle_t       ngx_cycle;
 
 
 #endif /* _NGX_HTTP_CONF_FILE_H_INCLUDED_ */
diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h
index 52ba59b..879dad3 100644
--- a/src/core/ngx_core.h
+++ b/src/core/ngx_core.h
@@ -58,10 +58,4 @@
 */
 
 
-#if 0
-/* STUB */
-extern ngx_log_t  ngx_log;
-#endif
-
-
 #endif /* _NGX_CORE_H_INCLUDED_ */
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index 51bae3d..2f8276b 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -210,12 +210,6 @@
 #endif
 
 
-static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
-{
-    return ngx_log_set_errlog(cf, cmd, &ngx_log);
-}
-
-
 
 ngx_log_t *ngx_log_init_errlog()
 {
@@ -252,11 +246,31 @@
 
     ngx_test_null(log, ngx_pcalloc(cycle->pool, sizeof(ngx_log_t)), NULL);
     ngx_test_null(log->file, ngx_push_array(&cycle->open_files), NULL);
+    log->file->fd = NGX_INVALID_FILE;
 
     return log;
 }
 
 
+static char *ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+    ngx_str_t  *value;
+
+    value = cf->args->elts;
+
+    if (value[1].len == 6 && ngx_strcmp(value[1].data, "stderr") == 0) {
+        cf->cycle->log->file = &ngx_stderr;
+
+    } else {
+        cf->cycle->log->file->name = value[1];
+    }
+
+    return NGX_CONF_OK;
+}
+
+
+#if 0
+
 char *ngx_log_set_errlog(ngx_conf_t *cf, ngx_command_t *cmd, ngx_log_t *log)
 {
     int         len;
@@ -297,3 +311,5 @@
 
     return NGX_CONF_OK;
 }
+
+#endif
diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h
index 0de8c3e..f180272 100644
--- a/src/core/ngx_log.h
+++ b/src/core/ngx_log.h
@@ -170,8 +170,6 @@
 ngx_log_t *ngx_log_init_errlog();
 ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle);
 
-char *ngx_log_set_errlog(ngx_conf_t *cf, ngx_command_t *cmd, ngx_log_t *log);
-
 
 extern ngx_module_t  ngx_errlog_module;