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;
diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c
index 51df43b..bdd1ff4 100644
--- a/src/event/modules/ngx_kqueue_module.c
+++ b/src/event/modules/ngx_kqueue_module.c
@@ -11,16 +11,13 @@
typedef struct {
- int kqueue;
- struct kevent *change_list;
u_int changes;
- struct kevent *event_list;
u_int events;
} ngx_kqueue_conf_t;
-static int ngx_kqueue_init(ngx_log_t *log);
-static void ngx_kqueue_done(ngx_log_t *log);
+static int ngx_kqueue_init(ngx_cycle_t *cycle);
+static void ngx_kqueue_done(ngx_cycle_t *cycle);
static int ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags);
static int ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags);
static int ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags);
@@ -72,10 +69,6 @@
NULL, /* delete an connection */
ngx_kqueue_process_events, /* process the events */
ngx_kqueue_init, /* init the events */
-#if 0
- ngx_kqueue_commit, /* commit the events */
- ngx_kqueue_rollback, /* rollback the events */
-#endif
ngx_kqueue_done /* done the events */
}
@@ -87,158 +80,27 @@
ngx_kqueue_commands, /* module directives */
NGX_EVENT_MODULE, /* module type */
NULL, /* init module */
- NULL, /* commit module */
- NULL, /* rollback module */
-#if 0
NULL /* init child */
-#endif
};
-#if 0
-static int ngx_kqueue_init(ngx_cycle_t *cycle, ngx_log_t *log)
+static int ngx_kqueue_init(ngx_cycle_t *cycle)
{
struct timespec ts;
ngx_kqueue_conf_t *kcf;
kcf = ngx_event_get_conf(cycle->conf_ctx, ngx_kqueue_module);
-ngx_log_debug(log, "CH: %d" _ kcf->changes);
-ngx_log_debug(log, "EV: %d" _ kcf->events);
-
- if (ngx_kqueue == -1) {
- kcf->kqueue = kqueue();
-
- if (kcf->kqueue == -1) {
- ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "kqueue() failed");
- return NGX_ERROR;
- }
-
- } else {
- kcf->kqueue = ngx_kqueue;
- }
-
- if (max_changes < kcf->changes) {
- if (nchanges) {
- ts.tv_sec = 0;
- ts.tv_nsec = 0;
-
- if (kevent(ngx_kqueue, change_list, nchanges, NULL, 0, &ts) == -1) {
- ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "kevent() failed");
- return NGX_ERROR;
- }
-
- nchanges = 0;
- }
-
- ngx_test_null(kcf->change_list,
- ngx_alloc(kcf->changes * sizeof(struct kevent), log),
- NGX_ERROR);
-
- } else {
- kcf->change_list = change_list;
- }
-
- if (nevents < kcf->events) {
- ngx_test_null(kcf->event_list,
- ngx_alloc(kcf->events * sizeof(struct kevent), log),
- NGX_ERROR);
- } else {
- kcf->event_list = event_list;
- }
-
- if (ngx_event_timer_init(cycle, log) == NGX_ERROR) {
- return NGX_ERROR;
- }
-
- return NGX_OK;
-}
-
-
-static void ngx_kqueue_commit(ngx_cycle_t *cycle, ngx_log_t *log)
-{
- ngx_kqueue_conf_t *kcf;
-
- kcf = ngx_event_get_conf(cycle->conf_ctx, ngx_kqueue_module);
-
- ngx_kqueue = kcf->kqueue;
-
- if (change_list != kcf->change_list) {
- ngx_free(change_list);
- change_list = kcf->change_list;
- }
-
- max_changes = kcf->changes;
-
- if (event_list != kcf->event_list) {
- ngx_free(event_list);
- event_list = kcf->event_list;
- }
-
- nevents = kcf->events;
-
- ngx_event_timer_commit(cycle, log);
-
- ngx_event_actions = ngx_kqueue_module_ctx.actions;
- ngx_io = ngx_os_io;
-
- ngx_event_flags = NGX_HAVE_LEVEL_EVENT
- |NGX_HAVE_ONESHOT_EVENT
-#if (HAVE_CLEAR_EVENT)
- |NGX_HAVE_CLEAR_EVENT
-#else
- |NGX_USE_LEVEL_EVENT
-#endif
-#if (HAVE_LOWAT_EVENT)
- |NGX_HAVE_LOWAT_EVENT
-#endif
- |NGX_HAVE_KQUEUE_EVENT;
-}
-
-
-static void ngx_kqueue_rollback(ngx_cycle_t *cycle, ngx_log_t *log)
-{
- ngx_kqueue_conf_t *kcf;
-
- kcf = ngx_event_get_conf(cycle->conf_ctx, ngx_kqueue_module);
-
- if (ngx_kqueue == -1) {
- if (close(kcf->kqueue) == -1) {
- ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
- "kqueue close() failed");
- }
- }
-
- if (change_list != kcf->change_list) {
- ngx_free(kcf->change_list);
- }
-
- if (event_list != kcf->event_list) {
- ngx_free(kcf->event_list);
- }
-
- ngx_event_timer_rollback(cycle, log);
-}
-
-#endif
-
-
-static int ngx_kqueue_init(ngx_log_t *log)
-{
- struct timespec ts;
- ngx_kqueue_conf_t *kcf;
-
- kcf = ngx_event_get_conf(ngx_kqueue_module);
-
-ngx_log_debug(log, "CH: %d" _ kcf->changes);
-ngx_log_debug(log, "EV: %d" _ kcf->events);
+ngx_log_debug(cycle->log, "CH: %d" _ kcf->changes);
+ngx_log_debug(cycle->log, "EV: %d" _ kcf->events);
if (ngx_kqueue == -1) {
ngx_kqueue = kqueue();
if (ngx_kqueue == -1) {
- ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "kqueue() failed");
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
+ "kqueue() failed");
return NGX_ERROR;
}
}
@@ -249,9 +111,11 @@
ts.tv_nsec = 0;
if (kevent(ngx_kqueue, change_list, nchanges, NULL, 0, &ts) == -1) {
- ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "kevent() failed");
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
+ "kevent() failed");
return NGX_ERROR;
}
+ nchanges = 0;
}
if (change_list) {
@@ -259,12 +123,12 @@
}
ngx_test_null(change_list,
- ngx_alloc(kcf->changes * sizeof(struct kevent), log),
+ ngx_alloc(kcf->changes * sizeof(struct kevent),
+ cycle->log),
NGX_ERROR);
}
max_changes = kcf->changes;
- nchanges = 0;
if (nevents < kcf->events) {
if (event_list) {
@@ -272,18 +136,18 @@
}
ngx_test_null(event_list,
- ngx_alloc(kcf->events * sizeof(struct kevent), log),
+ ngx_alloc(kcf->events * sizeof(struct kevent),
+ cycle->log),
NGX_ERROR);
}
nevents = kcf->events;
- if (ngx_event_timer_init(log) == NGX_ERROR) {
+ if (ngx_event_timer_init(cycle) == NGX_ERROR) {
return NGX_ERROR;
}
- /* TODO: re-add active events with new udata
- if ecf->connections was increased */
+ ngx_io = ngx_os_io;
ngx_event_actions = ngx_kqueue_module_ctx.actions;
@@ -303,15 +167,16 @@
}
-static void ngx_kqueue_done(ngx_log_t *log)
+static void ngx_kqueue_done(ngx_cycle_t *cycle)
{
if (close(ngx_kqueue) == -1) {
- ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "kqueue close() failed");
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
+ "kqueue close() failed");
}
ngx_kqueue = -1;
- ngx_event_timer_done(log);
+ ngx_event_timer_done(cycle);
ngx_free(change_list);
ngx_free(event_list);
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index b5d3b26..bc4386a 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -4,7 +4,7 @@
#include <ngx_event.h>
-#define DEF_CONNECTIONS 512
+#define DEFAULT_CONNECTIONS 512
extern ngx_module_t ngx_select_module;
@@ -21,6 +21,9 @@
#include <ngx_aio_module.h>
#endif
+static int ngx_event_init_module(ngx_cycle_t *cycle);
+static int ngx_event_init_child(ngx_cycle_t *cycle);
+static int ngx_event_init(ngx_cycle_t *cycle);
static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
@@ -31,15 +34,14 @@
int ngx_event_flags;
ngx_event_actions_t ngx_event_actions;
+int ngx_max_connections;
ngx_connection_t *ngx_connections;
ngx_event_t *ngx_read_events, *ngx_write_events;
-static int ngx_event_max_module;
+static int ngx_event_max_module;
-static int ngx_event_connections;
-
static ngx_str_t events_name = ngx_string("events");
@@ -61,7 +63,8 @@
&events_name, /* module context */
ngx_events_commands, /* module directives */
NGX_CORE_MODULE, /* module type */
- NULL /* init module */
+ NULL, /* init module */
+ NULL /* init child */
};
@@ -109,17 +112,15 @@
ngx_event_core_commands, /* module directives */
NGX_EVENT_MODULE, /* module type */
ngx_event_init_module, /* init module */
- ngx_event_commit, /* commit module */
- ngx_event_rollback, /* rollback module */
ngx_event_init_child /* init child */
};
-static int ngx_event_init_module(ngx_cycle_t *cycle, ngx_log_t *log)
+static int ngx_event_init_module(ngx_cycle_t *cycle)
{
if (cycle->one_process) {
- return ngx_event_init(cycle, log);
+ return ngx_event_init(cycle);
}
return NGX_OK;
@@ -128,18 +129,15 @@
static int ngx_event_init_child(ngx_cycle_t *cycle)
{
- if (!cycle->one_process) {
- if (ngx_event_init(cycle, cycle->log) == NGX_ERROR) {
- return NGX_ERROR;
- }
- ngx_event_commit(cycle, cycle->log);
+ if (cycle->one_process) {
+ return NGX_OK;
}
- return NGX_OK;
+ return ngx_event_init(cycle);
}
-static int ngx_event_init(ngx_cycle_t *cycle, ngx_log_t *log)
+static int ngx_event_init(ngx_cycle_t *cycle)
{
int m, i, fd;
ngx_event_t *rev, *wev;
@@ -153,8 +151,8 @@
ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module);
-ngx_log_debug(log, "CONN: %d" _ ecf->connections);
-ngx_log_debug(log, "TYPE: %d" _ ecf->use);
+ngx_log_debug(cycle->log, "CONN: %d" _ ecf->connections);
+ngx_log_debug(cycle->log, "TYPE: %d" _ ecf->use);
for (m = 0; ngx_modules[m]; m++) {
if (ngx_modules[m]->type != NGX_EVENT_MODULE) {
@@ -163,31 +161,37 @@
if (ngx_modules[m]->ctx_index == ecf->use) {
module = ngx_modules[m]->ctx;
- if (module->actions.init(log) == NGX_ERROR) {
+ if (module->actions.init(cycle) == NGX_ERROR) {
return NGX_ERROR;
}
break;
}
}
- if (ecf->connections) {
+ if (ngx_max_connections && ngx_max_connections < ecf->connections) {
+ /* TODO: push into delayed array and temporary pool */
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, "NOT READY");
+ exit(1);
}
+ ngx_max_connections = ecf->connections;
+
ngx_test_null(ngx_connections,
- ngx_alloc(sizeof(ngx_connection_t) * ecf->connections, log),
+ ngx_alloc(sizeof(ngx_connection_t) * ecf->connections,
+ cycle->log),
NGX_ERROR);
ngx_test_null(ngx_read_events,
- ngx_alloc(sizeof(ngx_event_t) * ecf->connections, log),
+ ngx_alloc(sizeof(ngx_event_t) * ecf->connections, cycle->log),
NGX_ERROR);
ngx_test_null(ngx_write_events,
- ngx_alloc(sizeof(ngx_event_t) * ecf->connections, log),
+ ngx_alloc(sizeof(ngx_event_t) * ecf->connections, cycle->log),
NGX_ERROR);
/* for each listening socket */
- for (s = ls->elts, i = 0; i < ls->nelts; i++) {
+ for (s = cycle->listening.elts, i = 0; i < cycle->listening.nelts; i++) {
fd = s[i].fd;
@@ -216,7 +220,8 @@
c->servers = s[i].servers;
c->log = s[i].log;
- ngx_test_null(rev->log, ngx_palloc(pool, sizeof(ngx_log_t)), NGX_ERROR);
+ ngx_test_null(rev->log, ngx_palloc(cycle->pool, sizeof(ngx_log_t)),
+ NGX_ERROR);
ngx_memcpy(rev->log, c->log, sizeof(ngx_log_t));
c->read = rev;
@@ -264,26 +269,6 @@
}
-static void ngx_event_commit(ngx_cycle_t *cycle, ngx_log_t *log)
-{
-}
-
-
-static void ngx_event_rollback(ngx_cycle_t *cycle, ngx_log_t *log)
-{
-}
-
-
-void ngx_worker(ngx_cycle_t *cycle)
-{
- for ( ;; ) {
- ngx_log_debug(cycle->log, "ngx_worker cycle");
-
- ngx_process_events(cycle->log);
- }
-}
-
-
static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
int m;
@@ -407,18 +392,18 @@
#if (HAVE_KQUEUE)
- ngx_conf_init_value(ecf->connections, DEF_CONNECTIONS);
+ ngx_conf_init_value(ecf->connections, DEFAULT_CONNECTIONS);
ngx_conf_init_value(ecf->use, ngx_kqueue_module.ctx_index);
#elif (HAVE_DEVPOLL)
- ngx_conf_init_value(ecf->connections, DEF_CONNECTIONS);
+ ngx_conf_init_value(ecf->connections, DEFAULT_CONNECTIONS);
ngx_conf_init_value(ecf->use, ngx_devpoll_module.ctx_index);
#else /* HAVE_SELECT */
ngx_conf_init_value(ecf->connections,
- FD_SETSIZE < DEF_CONNECTIONS ? FD_SETSIZE : DEF_CONNECTIONS);
+ FD_SETSIZE < DEFAULT_CONNECTIONS ? FD_SETSIZE : DEFAULT_CONNECTIONS);
ngx_conf_init_value(ecf->use, ngx_select_module.ctx_index);
diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h
index 393699f..2d64c11 100644
--- a/src/event/ngx_event.h
+++ b/src/event/ngx_event.h
@@ -151,8 +151,8 @@
int (*del_conn)(ngx_connection_t *c);
int (*process)(ngx_log_t *log);
- int (*init)(ngx_log_t *log);
- void (*done)(ngx_log_t *log);
+ int (*init)(ngx_cycle_t *cycle);
+ void (*done)(ngx_cycle_t *cycle);
} ngx_event_actions_t;
@@ -348,8 +348,8 @@
extern ngx_module_t ngx_event_core_module;
-#define ngx_event_get_conf(module) \
- (*(ngx_get_conf(ngx_events_module))) [module.ctx_index];
+#define ngx_event_get_conf(conf_ctx, module) \
+ (*(ngx_get_conf(conf_ctx, ngx_events_module))) [module.ctx_index];
diff --git a/src/event/ngx_event_accept.c b/src/event/ngx_event_accept.c
index 2d2eed4..a71dced 100644
--- a/src/event/ngx_event_accept.c
+++ b/src/event/ngx_event_accept.c
@@ -17,7 +17,7 @@
ngx_connection_t *c, *ls;
ngx_event_conf_t *ecf;
- ecf = ngx_event_get_conf(ngx_event_core_module);
+ ecf = ngx_event_get_conf(ngx_cycle.conf_ctx, ngx_event_core_module);
ls = ev->data;
diff --git a/src/event/ngx_event_timer.c b/src/event/ngx_event_timer.c
index 9ca3fe5..4122983 100644
--- a/src/event/ngx_event_timer.c
+++ b/src/event/ngx_event_timer.c
@@ -9,17 +9,18 @@
static int ngx_timer_queue_num;
-int ngx_event_timer_init(ngx_log_t *log)
+int ngx_event_timer_init(ngx_cycle_t *cycle)
{
int i;
ngx_event_t *new_queue;
ngx_event_conf_t *ecf;
- ecf = ngx_event_get_conf(ngx_event_core_module);
+ ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module);
if (ngx_timer_queue_num < ecf->timer_queues) {
ngx_test_null(new_queue,
- ngx_alloc(ecf->timer_queues * sizeof(ngx_event_t), log),
+ ngx_alloc(ecf->timer_queues * sizeof(ngx_event_t),
+ cycle->log),
NGX_ERROR);
for (i = 0; i < ngx_timer_queue_num; i++) {
@@ -39,16 +40,22 @@
ngx_timer_queue[i].timer_prev = &ngx_timer_queue[i];
ngx_timer_queue[i].timer_next = &ngx_timer_queue[i];
}
+
+ } else if (ngx_timer_queue_num > ecf->timer_queues) {
+ /* STUB */
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, "NOT READY");
+ exit(1);
}
return NGX_OK;;
}
-void ngx_event_timer_done(ngx_log_t *log)
+void ngx_event_timer_done(ngx_cycle_t *cycle)
{
ngx_free(ngx_timer_queue);
ngx_timer_queue = NULL;
+ ngx_timer_queue_num = 0;
}
diff --git a/src/event/ngx_event_timer.h b/src/event/ngx_event_timer.h
index 2704c58..7a6c52c 100644
--- a/src/event/ngx_event_timer.h
+++ b/src/event/ngx_event_timer.h
@@ -7,8 +7,8 @@
#include <ngx_event.h>
-int ngx_event_timer_init(ngx_log_t *log);
-void ngx_event_timer_done(ngx_log_t *log);
+int ngx_event_timer_init(ngx_cycle_t *cycle);
+void ngx_event_timer_done(ngx_cycle_t *cycle);
void ngx_event_add_timer(ngx_event_t *ev, ngx_msec_t timer);
int ngx_event_find_timer(void);
void ngx_event_expire_timers(ngx_msec_t timer);
diff --git a/src/http/modules/ngx_http_charset_filter.c b/src/http/modules/ngx_http_charset_filter.c
index bcddc92..50642ef 100644
--- a/src/http/modules/ngx_http_charset_filter.c
+++ b/src/http/modules/ngx_http_charset_filter.c
@@ -9,10 +9,10 @@
} ngx_http_charset_loc_conf_t;
+static int ngx_http_charset_filter_init(ngx_cycle_t *cycle);
static void *ngx_http_charset_create_loc_conf(ngx_pool_t *pool);
static char *ngx_http_charset_merge_loc_conf(ngx_pool_t *pool,
void *parent, void *child);
-static int ngx_http_charset_filter_init(ngx_cycle_t *cycle, ngx_log_t *log);
static ngx_command_t ngx_http_charset_filter_commands[] = {
@@ -46,8 +46,7 @@
ngx_http_charset_filter_commands, /* module directives */
NGX_HTTP_MODULE, /* module type */
ngx_http_charset_filter_init, /* init module */
- NULL, /* commit module */
- NULL /* rollback module */
+ NULL /* init child */
};
@@ -87,7 +86,7 @@
#endif
-static int ngx_http_charset_filter_init(ngx_cycle_t *cycle, ngx_log_t *log)
+static int ngx_http_charset_filter_init(ngx_cycle_t *cycle)
{
next_header_filter = ngx_http_top_header_filter;
ngx_http_top_header_filter = ngx_http_charset_header_filter;
diff --git a/src/http/modules/ngx_http_chunked_filter.c b/src/http/modules/ngx_http_chunked_filter.c
index 09b480b..8ace7dc 100644
--- a/src/http/modules/ngx_http_chunked_filter.c
+++ b/src/http/modules/ngx_http_chunked_filter.c
@@ -4,7 +4,7 @@
#include <ngx_http.h>
-static int ngx_http_chunked_filter_init(ngx_cycle_t *cycle, ngx_log_t *log);
+static int ngx_http_chunked_filter_init(ngx_cycle_t *cycle);
static ngx_http_module_t ngx_http_chunked_filter_module_ctx = {
@@ -25,8 +25,7 @@
NULL, /* module directives */
NGX_HTTP_MODULE, /* module type */
ngx_http_chunked_filter_init, /* init module */
- NULL, /* commit module */
- NULL /* rollback module */
+ NULL /* init child */
};
@@ -119,7 +118,7 @@
}
-static int ngx_http_chunked_filter_init(ngx_cycle_t *cycle, ngx_log_t *log)
+static int ngx_http_chunked_filter_init(ngx_cycle_t *cycle)
{
next_header_filter = ngx_http_top_header_filter;
ngx_http_top_header_filter = ngx_http_chunked_header_filter;
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c
index 9af0121..7051480 100644
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -14,7 +14,7 @@
static int ngx_http_index_test_dir(ngx_http_request_t *r);
-static int ngx_http_index_init(ngx_cycle_t *cycle, ngx_log_t *log);
+static int ngx_http_index_init(ngx_cycle_t *cycle);
static void *ngx_http_index_create_conf(ngx_pool_t *pool);
static char *ngx_http_index_merge_conf(ngx_pool_t *p, void *parent,
void *child);
@@ -53,8 +53,7 @@
ngx_http_index_commands, /* module directives */
NGX_HTTP_MODULE, /* module type */
ngx_http_index_init, /* init module */
- NULL, /* commit module */
- NULL /* rollback module */
+ NULL /* init child */
};
@@ -204,7 +203,7 @@
}
-static int ngx_http_index_init(ngx_cycle_t *cycle, ngx_log_t *log)
+static int ngx_http_index_init(ngx_cycle_t *cycle)
{
ngx_http_handler_pt *h;
ngx_http_conf_ctx_t *ctx;
diff --git a/src/http/modules/ngx_http_range_filter.c b/src/http/modules/ngx_http_range_filter.c
index 125551e..26c40c5 100644
--- a/src/http/modules/ngx_http_range_filter.c
+++ b/src/http/modules/ngx_http_range_filter.c
@@ -9,7 +9,7 @@
} ngx_http_range_filter_ctx_t;
-static int ngx_http_range_filter_init(ngx_cycle_t *cycle, ngx_log_t *log);
+static int ngx_http_range_filter_init(ngx_cycle_t *cycle);
static ngx_http_module_t ngx_http_range_filter_module_ctx = {
@@ -30,8 +30,7 @@
NULL, /* module directives */
NGX_HTTP_MODULE, /* module type */
ngx_http_range_filter_init, /* init module */
- NULL, /* commit module */
- NULL /* rollback module */
+ NULL /* init child */
};
@@ -356,7 +355,7 @@
}
-static int ngx_http_range_filter_init(ngx_cycle_t *cycle, ngx_log_t *log)
+static int ngx_http_range_filter_init(ngx_cycle_t *cycle)
{
next_header_filter = ngx_http_top_header_filter;
ngx_http_top_header_filter = ngx_http_range_header_filter;
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
index a1ea12a..b9a8528 100644
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -464,7 +464,7 @@
ls->nonblocking = 1;
ls->handler = ngx_http_init_connection;
- ls->log = cf->log;
+ ls->log = cf->cycle->log;
cscf = in_addr[a].core_srv_conf;
ls->pool_size = cscf->connection_pool_size;
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 8e9a966..7823eca 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -20,7 +20,7 @@
static char *ngx_http_core_merge_loc_conf(ngx_pool_t *pool,
void *parent, void *child);
-static int ngx_http_core_init(ngx_cycle_t *cycle, ngx_log_t *log);
+static int ngx_http_core_init(ngx_cycle_t *cycle);
static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy);
static int ngx_cmp_locations(const void *first, const void *second);
static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd,
@@ -187,8 +187,7 @@
ngx_http_core_commands, /* module directives */
NGX_HTTP_MODULE, /* module type */
ngx_http_core_init, /* init module */
- NULL, /* commit module */
- NULL /* rollback module */
+ NULL /* init child */
};
@@ -529,7 +528,7 @@
}
-static int ngx_http_core_init(ngx_cycle_t *cycle, ngx_log_t *log)
+static int ngx_http_core_init(ngx_cycle_t *cycle)
{
ngx_http_handler_pt *h;
ngx_http_conf_ctx_t *ctx;
diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c
index aa200c1..a34fdce 100644
--- a/src/http/ngx_http_header_filter.c
+++ b/src/http/ngx_http_header_filter.c
@@ -11,7 +11,7 @@
-static int ngx_http_header_filter_init(ngx_cycle_t *cycle, ngx_log_t *log);
+static int ngx_http_header_filter_init(ngx_cycle_t *cycle);
static int ngx_http_header_filter(ngx_http_request_t *r);
@@ -33,8 +33,7 @@
NULL, /* module directives */
NGX_HTTP_MODULE, /* module type */
ngx_http_header_filter_init, /* init module */
- NULL, /* commit module */
- NULL /* rollback module */
+ NULL /* init child */
};
@@ -389,7 +388,7 @@
}
-static int ngx_http_header_filter_init(ngx_cycle_t *cycle, ngx_log_t *log)
+static int ngx_http_header_filter_init(ngx_cycle_t *cycle)
{
ngx_http_top_header_filter = ngx_http_header_filter;
return NGX_OK;
diff --git a/src/http/ngx_http_write_filter.c b/src/http/ngx_http_write_filter.c
index fc96b07..1a9f928 100644
--- a/src/http/ngx_http_write_filter.c
+++ b/src/http/ngx_http_write_filter.c
@@ -18,7 +18,7 @@
static void *ngx_http_write_filter_create_conf(ngx_pool_t *pool);
static char *ngx_http_write_filter_merge_conf(ngx_pool_t *pool,
void *parent, void *child);
-static int ngx_http_write_filter_init(ngx_cycle_t *cycle, ngx_log_t *log);
+static int ngx_http_write_filter_init(ngx_cycle_t *cycle);
static ngx_command_t ngx_http_write_filter_commands[] = {
@@ -52,8 +52,7 @@
ngx_http_write_filter_commands, /* module directives */
NGX_HTTP_MODULE, /* module type */
ngx_http_write_filter_init, /* init module */
- NULL, /* commit module */
- NULL /* rollback module */
+ NULL /* init child */
};
@@ -189,7 +188,7 @@
}
-static int ngx_http_write_filter_init(ngx_cycle_t *cycle, ngx_log_t *log)
+static int ngx_http_write_filter_init(ngx_cycle_t *cycle)
{
ngx_http_top_body_filter = ngx_http_write_filter;