summaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/nginx.c74
-rw-r--r--src/core/ngx_string.h2
2 files changed, 41 insertions, 35 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;
diff --git a/src/core/ngx_string.h b/src/core/ngx_string.h
index 73ed43a95..9171ea073 100644
--- a/src/core/ngx_string.h
+++ b/src/core/ngx_string.h
@@ -46,7 +46,7 @@ typedef struct {
* msvc and icc compile memset() to inline "rep stos"
* while ZeroMemory and bzero are calls.
*/
-#define ngx_memzero(buf, n) memset(buf, n, 0)
+#define ngx_memzero(buf, n) memset(buf, 0, n)
/* msvc and icc compile memcpy() to inline "rep movs" */
#define ngx_memcpy(dst, src, n) memcpy(dst, src, n)