aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-11-19 16:26:41 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-11-19 16:26:41 +0000
commit160d774afcf3cdd4f999489211eb9d78bf82439a (patch)
tree59227d2698d9c531808a9f3edb708f36707a37f9 /src/core
parent1b138ed141c0bdb0c9944c1ae70e53682ed2d035 (diff)
downloadnginx-160d774afcf3cdd4f999489211eb9d78bf82439a.tar.gz
nginx-160d774afcf3cdd4f999489211eb9d78bf82439a.zip
nginx-0.0.1-2003-11-19-19:26:41 import
Diffstat (limited to 'src/core')
-rw-r--r--src/core/nginx.c78
-rw-r--r--src/core/nginx.h6
-rw-r--r--src/core/ngx_conf_file.h6
-rw-r--r--src/core/ngx_core.h1
-rw-r--r--src/core/ngx_log.c9
-rw-r--r--src/core/ngx_log.h4
6 files changed, 62 insertions, 42 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c
index b5e4392c0..ca056bd18 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -50,18 +50,19 @@ ngx_module_t ngx_core_module = {
};
-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 @@ int main(int argc, char *const *argv)
#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 @@ int main(int argc, char *const *argv)
/* life cycle */
for ( ;; ) {
- /* STUB */ ngx_cycle->log->log_level = NGX_LOG_DEBUG;
+ /* STUB */ cycle->log->log_level = NGX_LOG_DEBUG;
+
+#if 0
- /* forks */
+#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 @@ int main(int argc, char *const *argv)
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 @@ ngx_log_debug(log, "REOPEN: %d:%d:%s" _ fd _ file[i].fd _ file[i].name.data);
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 @@ ngx_log_debug(log, "REOPEN: %d:%d:%s" _ fd _ file[i].fd _ file[i].name.data);
#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 @@ ngx_log_debug(log, "REOPEN: %d:%d:%s" _ fd _ file[i].fd _ file[i].name.data);
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 @@ ngx_log_debug(log, "REOPEN: %d:%d:%s" _ fd _ file[i].fd _ file[i].name.data);
}
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 @@ ngx_log_debug(log, "OPEN: %d:%s" _ file[i].fd _ file[i].name.data);
}
}
- stub_init(cycle);
-
if (old_cycle == NULL) {
return cycle;
}
@@ -681,11 +689,13 @@ static int ngx_open_listening_sockets(ngx_cycle_t *cycle, ngx_log_t *log)
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 @@ static void ngx_clean_old_cycles(ngx_event_t *ev)
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 @@ static void ngx_clean_old_cycles(ngx_event_t *ev)
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 f58df7c8c..6a9fd493b 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 23f436e91..8a473bf5a 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -264,9 +264,9 @@ char *ngx_conf_set_core_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd,
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 ec8182b0a..0dc45bba3 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 61d49c7c2..a9ca9c363 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -91,12 +91,21 @@ void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
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 3eedfff6f..290b11c46 100644
--- a/src/core/ngx_log.h
+++ b/src/core/ngx_log.h
@@ -66,7 +66,7 @@ typedef enum {
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 @@ typedef struct {
char *context;
/* */
#endif
-} ngx_log_t;
+};
#define MAX_ERROR_STR 2048