ngx_pool_t *pool;
ngx_cycle_t *cycle, **old;
ngx_socket_t fd;
+ ngx_list_part_t *part;
ngx_open_file_t *file;
ngx_listening_t *ls, *nls;
ngx_core_module_t *module;
cycle->pathes.pool = pool;
+ if (old_cycle->open_files.part.nelts) {
+ n = old_cycle->open_files.part.nelts;
+ for (part = old_cycle->open_files.part.next; part; part = part->next) {
+ n += part->nelts;
+ }
+
+ } else {
+ n = 20;
+ }
+
+ cycle->open_files.part.elts = ngx_palloc(pool, n * sizeof(ngx_open_file_t));
+ if (cycle->open_files.part.elts == NULL) {
+ ngx_destroy_pool(pool);
+ return NULL;
+ }
+ cycle->open_files.part.nelts = 0;
+ cycle->open_files.part.next = NULL;
+ cycle->open_files.last = &cycle->open_files.part;
+ cycle->open_files.size = sizeof(ngx_open_file_t);
+ cycle->open_files.nalloc = n;
+ cycle->open_files.pool = pool;
+
+
+#if 0
n = old_cycle->open_files.nelts ? 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) {
cycle->open_files.size = sizeof(ngx_open_file_t);
cycle->open_files.nalloc = n;
cycle->open_files.pool = pool;
+#endif
if (!(cycle->new_log = ngx_log_create_errlog(cycle, NULL))) {
if (!failed) {
+
+ part = &cycle->open_files.part;
+ file = part->elts;
+
+ for (i = 0; /* void */ ; i++) {
+
+ if (i >= part->nelts) {
+ if (part->next == NULL) {
+ break;
+ }
+ part = part->next;
+ file = part->elts;
+ i = 0;
+ }
+
+#if 0
file = cycle->open_files.elts;
for (i = 0; i < cycle->open_files.nelts; i++) {
+#endif
+
if (file[i].name.data == NULL) {
continue;
}
NGX_FILE_RDWR,
NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
+ log->log_level = NGX_LOG_DEBUG_ALL;
+ ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0,
+ "log: %0X %d \"%s\"",
+ &file[i], file[i].fd, file[i].name.data);
+
if (file[i].fd == NGX_INVALID_FILE) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
ngx_open_file_n " \"%s\" failed",
#if !(WIN32)
if (!failed && !ngx_test_config) {
+
+ ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0,
+ "dup2: %0X %d \"%s\"",
+ cycle->log->file,
+ cycle->log->file->fd, cycle->log->file->name.data);
+
if (dup2(cycle->log->file->fd, STDERR_FILENO) == NGX_ERROR) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
"dup2(STDERR) failed");
/* rollback the new cycle configuration */
+ part = &cycle->open_files.part;
+ file = part->elts;
+
+ for (i = 0; /* void */ ; i++) {
+
+ if (i >= part->nelts) {
+ if (part->next == NULL) {
+ break;
+ }
+ part = part->next;
+ file = part->elts;
+ i = 0;
+ }
+
+#if 0
file = cycle->open_files.elts;
for (i = 0; i < cycle->open_files.nelts; i++) {
+#endif
+
if (file[i].fd == NGX_INVALID_FILE) {
continue;
}
ls = cycle->listening.elts;
for (i = 0; i < cycle->listening.nelts; i++) {
- if (ls[i].new && ls[i].fd == -1) {
+ if (ls[i].fd == -1 || !ls[i].new) {
continue;
}
/* close the unneeded open files */
+ part = &old_cycle->open_files.part;
+ file = part->elts;
+
+ for (i = 0; /* void */ ; i++) {
+
+ if (i >= part->nelts) {
+ if (part->next == NULL) {
+ break;
+ }
+ part = part->next;
+ file = part->elts;
+ i = 0;
+ }
+
+#if 0
file = old_cycle->open_files.elts;
for (i = 0; i < old_cycle->open_files.nelts; i++) {
+#endif
+
if (file[i].fd == NGX_INVALID_FILE) {
continue;
}
{
ngx_fd_t fd;
ngx_uint_t i;
+ ngx_list_part_t *part;
ngx_open_file_t *file;
+ part = &cycle->open_files.part;
+ file = part->elts;
+
+ for (i = 0; /* void */ ; i++) {
+
+ if (i >= part->nelts) {
+ if (part->next == NULL) {
+ break;
+ }
+ part = part->next;
+ i = 0;
+ }
+
+#if 0
file = cycle->open_files.elts;
for (i = 0; i < cycle->open_files.nelts; i++) {
+#endif
+
if (file[i].name.data == NULL) {
continue;
}
--- /dev/null
+#ifndef _NGX_LIST_H_INCLUDED_
+#define _NGX_LIST_H_INCLUDED_
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+typedef struct ngx_list_part_s ngx_list_part_t;
+
+struct ngx_list_part_s {
+ void *elts;
+ ngx_uint_t nelts;
+ ngx_list_part_t *next;
+};
+
+
+typedef struct {
+ ngx_list_part_t *last;
+ ngx_list_part_t part;
+ size_t size;
+ ngx_uint_t nalloc;
+ ngx_pool_t *pool;
+} ngx_list_t;
+
+
+#define ngx_init_list(l, p, n, s, rc) \
+ if (!(l.part.elts = ngx_palloc(p, n * s))) { \
+ return rc; \
+ } \
+ l.part.nelts = 0; l.part.next = NULL; \
+ l.last = &l.part; l.size = s; l.nalloc = n; l.pool = p;
+
+
+#define ngx_iterate_list(p, i) \
+ for ( ;; i++) { \
+ if (i >= p->nelts) { \
+ if (p->next == NULL) { \
+ break; \
+ } \
+ p = p->next; i = 0; \
+ }
+
+
+void *ngx_push_list(ngx_list_t *list);
+
+
+#endif /* _NGX_LIST_H_INCLUDED_ */