aboutsummaryrefslogtreecommitdiff
path: root/src/core/nginx.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-07-02 18:51:41 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-07-02 18:51:41 +0000
commit9d9f58f24d318dad43c7019c40a187555aaa64c8 (patch)
tree0600e4a1f78cf9359472e204604008732e4b301e /src/core/nginx.c
parent96c56c9ab6e73f9d92242fdc4f0cc3b64495bd23 (diff)
downloadnginx-9d9f58f24d318dad43c7019c40a187555aaa64c8.tar.gz
nginx-9d9f58f24d318dad43c7019c40a187555aaa64c8.zip
nginx-0.0.1-2003-07-02-22:51:41 import
Diffstat (limited to 'src/core/nginx.c')
-rw-r--r--src/core/nginx.c74
1 files changed, 40 insertions, 34 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 1c54a8c1f..30ebf3fe9 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -15,17 +15,12 @@ void ****ngx_conf_ctx;
ngx_os_io_t ngx_io;
+ngx_cycle_t *cycle;
+
int ngx_max_module;
-#if 0
-void *ctx_conf;
-#endif
int ngx_connection_counter;
-#if 0
-ngx_array_t ngx_listening_sockets;
-#endif
-
#if 1
@@ -33,8 +28,7 @@ int main(int argc, char *const *argv)
{
int i;
ngx_log_t *log;
- ngx_conf_t conf;
- ngx_cycle_t *cycle, *new_cycle;
+ ngx_cycle_t *new_cycle;
/* TODO */ ngx_max_sockets = -1;
@@ -60,10 +54,16 @@ int main(int argc, char *const *argv)
for ( ;; ) {
+ /* STUB */
+ ngx_io = ngx_os_io;
+
/* forks */
ngx_init_temp_number();
+ /* STUB */
+ ngx_pre_thread(&cycle->listening, cycle->pool, cycle->log);
+
/* threads */
for ( ;; ) {
@@ -107,12 +107,6 @@ static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log)
}
cycle->pool = pool;
- cycle->log = ngx_log_create_errlog(cycle);
- if (cycle->log == NULL) {
- ngx_destroy_pool(pool);
- return NULL;
- }
-
n = old_cycle ? old_cycle->open_files.nelts : 20;
cycle->open_files.elts = ngx_pcalloc(pool, n * sizeof(ngx_open_file_t));
if (cycle->open_files.elts == NULL) {
@@ -124,6 +118,12 @@ static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log)
cycle->open_files.nalloc = n;
cycle->open_files.pool = pool;
+ cycle->log = ngx_log_create_errlog(cycle);
+ if (cycle->log == NULL) {
+ ngx_destroy_pool(pool);
+ return NULL;
+ }
+
n = old_cycle ? old_cycle->listening.nelts : 10;
cycle->listening.elts = ngx_pcalloc(pool, n * sizeof(ngx_listening_t));
if (cycle->listening.elts == NULL) {
@@ -151,7 +151,7 @@ static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log)
conf.ctx = cycle->conf_ctx;
conf.cycle = cycle;
- /* STUB */ conf.pool = cycle->pool;
+ /* STUB */ conf.pool = cycle->pool; ngx_conf_ctx = cycle->conf_ctx;
conf.log = log;
conf.module_type = NGX_CORE_MODULE;
conf.cmd_type = NGX_MAIN_CONF;
@@ -200,25 +200,27 @@ static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log)
}
if (!failed) {
- ls = old_cycle->listening.elts;
- for (i = 0; i < old_cycle->listening.nelts; i++) {
- ls[i].remain = 0;
- }
-
- nls = cycle->listening.elts;
- for (n = 0; n < cycle->listening.nelts; n++) {
+ if (old_cycle) {
+ ls = old_cycle->listening.elts;
for (i = 0; i < old_cycle->listening.nelts; i++) {
- if (ngx_memcmp(nls[n].sockaddr,
- ls[i].sockaddr, ls[i].socklen) == 0)
- {
- nls[n].fd = ls[i].fd;
- ls[i].remain = 1;
- break;
- }
+ ls[i].remain = 0;
}
- if (nls[n].fd == -1) {
- nls[n].new = 1;
+ nls = cycle->listening.elts;
+ for (n = 0; n < cycle->listening.nelts; n++) {
+ for (i = 0; i < old_cycle->listening.nelts; i++) {
+ if (ngx_memcmp(nls[n].sockaddr,
+ ls[i].sockaddr, ls[i].socklen) == 0)
+ {
+ nls[n].fd = ls[i].fd;
+ ls[i].remain = 1;
+ break;
+ }
+ }
+
+ if (nls[n].fd == -1) {
+ nls[n].new = 1;
+ }
}
}
@@ -275,6 +277,12 @@ static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log)
}
}
+ pool->log = cycle->log;
+
+ if (old_cycle == NULL) {
+ return cycle;
+ }
+
ls = old_cycle->listening.elts;
for (i = 0; i < old_cycle->listening.nelts; i++) {
if (ls[i].remain) {
@@ -301,8 +309,6 @@ static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log)
}
}
- pool->log = cycle->log;
-
ngx_destroy_pool(old_cycle->pool);
return cycle;