summaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-07-04 15:10:33 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-07-04 15:10:33 +0000
commit340b03b201c77f394cc70fda4d960ad6c3b68905 (patch)
treec4a4fd6a958f2ae6c5ebed768e2c461197219df2 /src/core
parentbe3c2b69a4c18e3810b1ed1ba407f0be37230c27 (diff)
downloadnginx-340b03b201c77f394cc70fda4d960ad6c3b68905.tar.gz
nginx-340b03b201c77f394cc70fda4d960ad6c3b68905.tar.bz2
nginx-0.0.1-2003-07-04-19:10:33 import
Diffstat (limited to 'src/core')
-rw-r--r--src/core/nginx.c103
-rw-r--r--src/core/ngx_conf_file.h9
-rw-r--r--src/core/ngx_core.h6
-rw-r--r--src/core/ngx_log.c28
-rw-r--r--src/core/ngx_log.h2
5 files changed, 76 insertions, 72 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 89dd6f04e..fb3457876 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -15,7 +15,7 @@ void ****ngx_conf_ctx;
ngx_os_io_t ngx_io;
-ngx_cycle_t *cycle;
+ngx_cycle_t ngx_cycle;
int ngx_max_module;
@@ -30,7 +30,7 @@ int main(int argc, char *const *argv)
{
int i;
ngx_log_t *log;
- ngx_cycle_t *new_cycle;
+ ngx_cycle_t *cycle;
/* TODO */ ngx_max_sockets = -1;
@@ -50,23 +50,27 @@ int main(int argc, char *const *argv)
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 @@ int main(int argc, char *const *argv)
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,39 +193,33 @@ static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log)
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);
- if (!failed) {
- file = cycle->open_files.elts;
- for (i = 0; i < cycle->open_files.nelts; i++) {
- if (file->name.data == NULL) {
- continue;
- }
+ 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);
+ 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 (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) {
ls = old_cycle->listening.elts;
@@ -254,12 +254,6 @@ static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log)
/* 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 @@ static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log)
/* 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 932f5bf93..7e0010d1e 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -79,9 +79,8 @@ struct ngx_module_s {
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 @@ struct ngx_conf_s {
};
-#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 @@ char *ngx_conf_set_time_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
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 52ba59b57..879dad357 100644
--- a/src/core/ngx_core.h
+++ b/src/core/ngx_core.h
@@ -58,10 +58,4 @@ typedef struct ngx_connection_s ngx_connection_t;
*/
-#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 51bae3d1a..2f8276bb6 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -210,12 +210,6 @@ void ngx_log_stderr(ngx_event_t *ev)
#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_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle)
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 @@ char *ngx_log_set_errlog(ngx_conf_t *cf, ngx_command_t *cmd, ngx_log_t *log)
return NGX_CONF_OK;
}
+
+#endif
diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h
index 0de8c3edd..f18027277 100644
--- a/src/core/ngx_log.h
+++ b/src/core/ngx_log.h
@@ -170,8 +170,6 @@ void ngx_assert_core(ngx_log_t *log, const char *fmt, ...);
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;