Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2009-03-23 16:14:51 +0300
committerIgor Sysoev <igor@sysoev.ru>2009-03-23 16:14:51 +0300
commit52859f2f1309fc8452f1cf182b712ae2d72bc40c (patch)
treef87d424675f857d0dcebdc80ce3828389d75a69b /src/os
parent1af7090b5091ebbee1cd9354fe8a702e601a8ce0 (diff)
a prelimiary proxy cache support
Diffstat (limited to 'src/os')
-rw-r--r--src/os/unix/ngx_files.h1
-rw-r--r--src/os/unix/ngx_process_cycle.c106
-rw-r--r--src/os/win32/ngx_files.h1
3 files changed, 68 insertions, 40 deletions
diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h
index 068b4d8fd..21e5ff45c 100644
--- a/src/os/unix/ngx_files.h
+++ b/src/os/unix/ngx_files.h
@@ -67,6 +67,7 @@ typedef struct {
#define NGX_FILE_APPEND O_APPEND
#define NGX_FILE_DEFAULT_ACCESS 0644
+#define NGX_FILE_OWNER_ACCESS 0600
#define ngx_close_file close
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
index a14a03c74..354722052 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -12,7 +12,7 @@
static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n,
ngx_int_t type);
-static void ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type);
+static void ngx_start_cleaner_process(ngx_cycle_t *cycle, ngx_int_t type);
static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo);
static ngx_uint_t ngx_reap_children(ngx_cycle_t *cycle);
static void ngx_master_process_exit(ngx_cycle_t *cycle);
@@ -24,9 +24,8 @@ static void ngx_channel_handler(ngx_event_t *ev);
static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle);
static ngx_thread_value_t ngx_worker_thread_cycle(void *data);
#endif
-#if 0
-static void ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data);
-#endif
+static void ngx_cleaner_process_cycle(ngx_cycle_t *cycle, void *data);
+static void ngx_cleaner_process_handler(ngx_event_t *ev);
ngx_uint_t ngx_process;
@@ -123,7 +122,7 @@ ngx_master_process_cycle(ngx_cycle_t *cycle)
ngx_start_worker_processes(cycle, ccf->worker_processes,
NGX_PROCESS_RESPAWN);
- ngx_start_garbage_collector(cycle, NGX_PROCESS_RESPAWN);
+ ngx_start_cleaner_process(cycle, NGX_PROCESS_RESPAWN);
ngx_new_binary = 0;
delay = 0;
@@ -204,7 +203,7 @@ ngx_master_process_cycle(ngx_cycle_t *cycle)
if (ngx_new_binary) {
ngx_start_worker_processes(cycle, ccf->worker_processes,
NGX_PROCESS_RESPAWN);
- ngx_start_garbage_collector(cycle, NGX_PROCESS_RESPAWN);
+ ngx_start_cleaner_process(cycle, NGX_PROCESS_RESPAWN);
ngx_noaccepting = 0;
continue;
@@ -223,7 +222,7 @@ ngx_master_process_cycle(ngx_cycle_t *cycle)
ngx_core_module);
ngx_start_worker_processes(cycle, ccf->worker_processes,
NGX_PROCESS_JUST_RESPAWN);
- ngx_start_garbage_collector(cycle, NGX_PROCESS_JUST_RESPAWN);
+ ngx_start_cleaner_process(cycle, NGX_PROCESS_JUST_RESPAWN);
live = 1;
ngx_signal_worker_processes(cycle,
ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
@@ -233,7 +232,7 @@ ngx_master_process_cycle(ngx_cycle_t *cycle)
ngx_restart = 0;
ngx_start_worker_processes(cycle, ccf->worker_processes,
NGX_PROCESS_RESPAWN);
- ngx_start_garbage_collector(cycle, NGX_PROCESS_RESPAWN);
+ ngx_start_cleaner_process(cycle, NGX_PROCESS_RESPAWN);
live = 1;
}
@@ -361,18 +360,28 @@ ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
static void
-ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type)
+ngx_start_cleaner_process(ngx_cycle_t *cycle, ngx_int_t type)
{
-#if 0
- ngx_int_t i;
- ngx_channel_t ch;
+ ngx_int_t i;
+ ngx_uint_t n;
+ ngx_path_t **path;
+ ngx_channel_t ch;
+
+ path = ngx_cycle->pathes.elts;
+ for (n = 0; n < ngx_cycle->pathes.nelts; n++) {
+ if (path[n]->cleaner) {
+ goto start;
+ }
+ }
- ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start garbage collector");
+ return;
+
+start:
ch.command = NGX_CMD_OPEN_CHANNEL;
- ngx_spawn_process(cycle, ngx_garbage_collector_cycle, NULL,
- "garbage collector", type);
+ ngx_spawn_process(cycle, ngx_cleaner_process_cycle, NULL,
+ "cleaner process", type);
ch.pid = ngx_processes[ngx_process_slot].pid;
ch.slot = ngx_process_slot;
@@ -398,7 +407,6 @@ ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type)
ngx_write_channel(ngx_processes[i].channel[0],
&ch, sizeof(ngx_channel_t), cycle->log);
}
-#endif
}
@@ -1254,27 +1262,29 @@ ngx_worker_thread_cycle(void *data)
#endif
-#if 0
-
static void
-ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data)
+ngx_cleaner_process_cycle(ngx_cycle_t *cycle, void *data)
{
- ngx_uint_t i;
- ngx_gc_t ctx;
- ngx_path_t **path;
- ngx_event_t *ev;
+ void *ident[4];
+ ngx_event_t ev;
+
+ cycle->connection_n = 512;
ngx_worker_process_init(cycle, 0);
- ev = &cycle->read_events0[ngx_channel];
+ ngx_close_listening_sockets(cycle);
- ngx_accept_mutex = NULL;
+ ngx_memzero(&ev, sizeof(ngx_event_t));
+ ev.handler = ngx_cleaner_process_handler;
+ ev.data = ident;
+ ev.log = cycle->log;
+ ident[3] = (void *) -1;
- ngx_setproctitle("garbage collector");
+ ngx_use_accept_mutex = 0;
-#if 0
- ngx_add_timer(ev, 60 * 1000);
-#endif
+ ngx_setproctitle("cleaner process");
+
+ ngx_add_timer(&ev, 0);
for ( ;; ) {
@@ -1289,19 +1299,35 @@ ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data)
ngx_reopen_files(cycle, -1);
}
- path = cycle->pathes.elts;
- for (i = 0; i < cycle->pathes.nelts; i++) {
- ctx.path = path[i];
- ctx.log = cycle->log;
- ctx.handler = path[i]->cleaner;
+ ngx_process_events_and_timers(cycle);
+ }
+}
- ngx_collect_garbage(&ctx, &path[i]->name, 0);
- }
- ngx_add_timer(ev, 60 * 60 * 1000);
+static void
+ngx_cleaner_process_handler(ngx_event_t *ev)
+{
+ time_t next, n;
+ ngx_uint_t i;
+ ngx_path_t **path;
+
+ next = 60 * 60;
- ngx_process_events_and_timers(cycle);
+ path = ngx_cycle->pathes.elts;
+ for (i = 0; i < ngx_cycle->pathes.nelts; i++) {
+
+ if (path[i]->cleaner) {
+ n = path[i]->cleaner(path[i]->data);
+
+ next = (n <= next) ? n : next;
+
+ ngx_time_update(0, 0);
+ }
}
-}
-#endif
+ if (next == 0) {
+ next = 1;
+ }
+
+ ngx_add_timer(ev, next * 1000);
+}
diff --git a/src/os/win32/ngx_files.h b/src/os/win32/ngx_files.h
index 5855e673f..b8487920f 100644
--- a/src/os/win32/ngx_files.h
+++ b/src/os/win32/ngx_files.h
@@ -75,6 +75,7 @@ typedef struct {
#define NGX_FILE_APPEND 0
#define NGX_FILE_DEFAULT_ACCESS 0
+#define NGX_FILE_OWNER_ACCESS 0
ngx_int_t ngx_file_append_mode(ngx_fd_t fd);