nginx-0.0.1-2003-11-19-19:26:41 import
diff --git a/src/core/nginx.c b/src/core/nginx.c
index b5e4392..ca056bd 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -50,18 +50,19 @@
 };
 
 
-int           ngx_max_module;
-ngx_os_io_t   ngx_io;
+int                    ngx_max_module;
+ngx_os_io_t            ngx_io;
 
-ngx_cycle_t  *ngx_cycle;
-ngx_pool_t   *ngx_temp_pool;
-ngx_array_t   ngx_old_cycles;
-ngx_event_t   ngx_cleaner_event;
+volatile ngx_cycle_t  *ngx_cycle;
+ngx_array_t            ngx_old_cycles;
+
+static ngx_pool_t     *ngx_temp_pool;
+static ngx_event_t     ngx_cleaner_event;
 
 /* STUB NAME */
-ngx_connection_t  dumb;
+static ngx_connection_t  dumb;
 
-int ngx_connection_counter;
+u_int ngx_connection_counter;
 
 
 int restart;
@@ -112,17 +113,16 @@
 
 #if !(WIN32)
 
-    ccf = (ngx_core_conf_t *) ngx_get_conf(ngx_cycle->conf_ctx,
-                                           ngx_core_module);
+    ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
 
     if (ccf->daemon != 0) {
-        if (ngx_daemon(ngx_cycle->log) == NGX_ERROR) {
+        if (ngx_daemon(cycle->log) == NGX_ERROR) {
             return 1;
         }
     }
 
-    if (dup2(ngx_cycle->log->file->fd, STDERR_FILENO) == -1) {
-        ngx_log_error(NGX_LOG_EMERG, ngx_cycle->log, ngx_errno,
+    if (dup2(cycle->log->file->fd, STDERR_FILENO) == -1) {
+        ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
                       "dup2(STDERR) failed");
         return 1;
     }
@@ -132,22 +132,31 @@
     /* life cycle */
 
     for ( ;; ) {
-        /* STUB */ ngx_cycle->log->log_level = NGX_LOG_DEBUG;
+        /* STUB */ cycle->log->log_level = NGX_LOG_DEBUG;
 
-        /* forks */
+#if 0
+
+#if !(WIN32)
+        ngx_spawn_process(cycle->log);
+#endif
+
+        stub_init(cycle);
+#endif
+
+        /* TODO: forks */
 
         ngx_init_temp_number();
 
         for (i = 0; ngx_modules[i]; i++) {
             if (ngx_modules[i]->init_child) {
-                if (ngx_modules[i]->init_child(ngx_cycle) == NGX_ERROR) {
+                if (ngx_modules[i]->init_child(cycle) == NGX_ERROR) {
                     /* fatal */
                     exit(1);
                 }
             }
         }
 
-        /* threads */
+        /* TODO: threads */
 
         restart = 0;
         rotate = 0;
@@ -155,12 +164,12 @@
         for ( ;; ) {
 
             for ( ;; ) {
-                ngx_log_debug(ngx_cycle->log, "worker cycle");
+                ngx_log_debug(cycle->log, "worker cycle");
 
-                ngx_process_events(ngx_cycle->log);
+                ngx_process_events(cycle->log);
 
                 if (rotate) {
-                    ngx_log_debug(ngx_cycle->log, "rotate");
+                    ngx_log_debug(cycle->log, "rotate");
 
                     file = cycle->open_files.elts;
                     for (i = 0; i < cycle->open_files.nelts; i++) {
@@ -176,7 +185,7 @@
 
                         if (fd == NGX_INVALID_FILE) {
                             ngx_log_error(NGX_LOG_EMERG,
-                                          ngx_cycle->log, ngx_errno,
+                                          cycle->log, ngx_errno,
                                           ngx_open_file_n " \"%s\" failed",
                                           file[i].name.data);
                             continue;
@@ -185,14 +194,14 @@
 #if (WIN32)
                         if (ngx_file_append_mode(fd) == NGX_ERROR) {
                             ngx_log_error(NGX_LOG_EMERG,
-                                          ngx_cycle->log, ngx_errno,
+                                          cycle->log, ngx_errno,
                                           ngx_file_append_mode_n
                                           " \"%s\" failed",
                                           file[i].name.data);
 
                             if (ngx_close_file(fd) == NGX_FILE_ERROR) {
                                 ngx_log_error(NGX_LOG_EMERG,
-                                              ngx_cycle->log, ngx_errno,
+                                              cycle->log, ngx_errno,
                                               ngx_close_file_n " \"%s\" failed",
                                               file[i].name.data);
                             }
@@ -203,7 +212,7 @@
 
                         if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) {
                             ngx_log_error(NGX_LOG_EMERG,
-                                          ngx_cycle->log, ngx_errno,
+                                          cycle->log, ngx_errno,
                                           ngx_close_file_n " \"%s\" failed",
                                           file[i].name.data);
                         }
@@ -213,14 +222,15 @@
                 }
 
                 if (restart) {
-                    ngx_log_debug(ngx_cycle->log, "restart");
+                    ngx_log_debug(cycle->log, "restart");
                     break;
                 }
 
             }
 
-            cycle = ngx_init_cycle(ngx_cycle, ngx_cycle->log);
+            cycle = ngx_init_cycle(cycle, cycle->log);
             if (cycle == NULL) {
+                cycle = (ngx_cycle_t*) ngx_cycle;
                 continue;
             }
 
@@ -464,8 +474,6 @@
         }
     }
 
-    stub_init(cycle);
-
     if (old_cycle == NULL) {
         return cycle;
     }
@@ -681,11 +689,13 @@
 static void ngx_clean_old_cycles(ngx_event_t *ev)
 {
     int            i, n, found, live;
+    ngx_log_t     *log;
     ngx_cycle_t  **cycle;
 
-    ngx_temp_pool->log = ngx_cycle->log;
+    log = ngx_cycle->log;
+    ngx_temp_pool->log = log;
 
-    ngx_log_debug(ngx_cycle->log, "clean old cycles");
+    ngx_log_debug(log, "clean old cycles");
 
     live = 0;
 
@@ -701,7 +711,7 @@
         for (n = 0; n < cycle[i]->connection_n; n++) {
             if (cycle[i]->connections[n].fd != -1) {
                 found = 1;
-                ngx_log_debug(ngx_cycle->log, "live fd: %d" _ n);
+                ngx_log_debug(log, "live fd: %d" _ n);
                 break;
             }
         }
@@ -711,15 +721,15 @@
             continue;
         }
 
-        ngx_log_debug(ngx_cycle->log, "clean old cycle: %d" _ i);
+        ngx_log_debug(log, "clean old cycle: %d" _ i);
         ngx_destroy_pool(cycle[i]->pool);
         cycle[i] = NULL;
     }
 
-    ngx_log_debug(ngx_cycle->log, "old cycles status: %d" _ live);
+    ngx_log_debug(log, "old cycles status: %d" _ live);
 
     if (live) {
-        ngx_log_debug(ngx_cycle->log, "TIMER");
+        ngx_log_debug(log, "TIMER");
         ngx_add_timer(ev, 30000);
 
     } else {
diff --git a/src/core/nginx.h b/src/core/nginx.h
index f58df7c..6a9fd49 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -6,10 +6,10 @@
 #define  NGINX_CONF  "nginx.conf"
 
 
-extern int ngx_max_module;
-extern int ngx_connection_counter;
+extern int           ngx_max_module;
+extern u_int         ngx_connection_counter;
 
-extern ngx_module_t ngx_core_module;
+extern ngx_module_t  ngx_core_module;
 
 
 
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index 23f436e..8a473bf 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -264,9 +264,9 @@
                                   void *conf);
 
 
-extern ngx_module_t     *ngx_modules[];
-extern ngx_cycle_t      *ngx_cycle;
-extern ngx_array_t       ngx_old_cycles;
+extern ngx_module_t          *ngx_modules[];
+extern volatile ngx_cycle_t  *ngx_cycle;
+extern ngx_array_t            ngx_old_cycles;
 
 
 #endif /* _NGX_HTTP_CONF_FILE_H_INCLUDED_ */
diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h
index ec8182b..0dc45bb 100644
--- a/src/core/ngx_core.h
+++ b/src/core/ngx_core.h
@@ -5,6 +5,7 @@
 typedef struct ngx_module_s      ngx_module_t;
 typedef struct ngx_conf_s        ngx_conf_t;
 typedef struct ngx_cycle_s       ngx_cycle_t;
+typedef struct ngx_log_s         ngx_log_t;
 typedef struct ngx_open_file_s   ngx_open_file_t;
 typedef struct ngx_command_s     ngx_command_t;
 
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index 61d49c7..a9ca9c3 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -91,12 +91,21 @@
     len += ngx_snprintf(errstr + len, sizeof(errstr) - len - 1,
                         PID_FMT "#%d: ", ngx_getpid(), 0);
 
+    if (log->data) {
+        len += ngx_snprintf(errstr + len, sizeof(errstr) - len - 1,
+                            "*%u ", * (u_int *) log->data);
+    }
+
 #if (HAVE_VARIADIC_MACROS)
+
     va_start(args, fmt);
     len += ngx_vsnprintf(errstr + len, sizeof(errstr) - len - 1, fmt, args);
     va_end(args);
+
 #else
+
     len += ngx_vsnprintf(errstr + len, sizeof(errstr) - len - 1, fmt, args);
+
 #endif
 
     if (err) {
diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h
index 3eedfff..290b11c 100644
--- a/src/core/ngx_log.h
+++ b/src/core/ngx_log.h
@@ -66,7 +66,7 @@
 typedef size_t  (*ngx_log_handler_pt) (void *ctx, char *buf, size_t len);
 
 
-typedef struct {
+struct ngx_log_s {
     int                  log_level;
     ngx_open_file_t     *file;
     void                *data;
@@ -78,7 +78,7 @@
     char     *context;
 /* */
 #endif
-} ngx_log_t;
+};
 
 #define MAX_ERROR_STR	2048