comparison src/os/unix/ngx_process_cycle.c @ 468:56baf312c1b5 NGINX_0_7_46

nginx 0.7.46 *) Bugfix: the previous release tarball was incorrect.
author Igor Sysoev <http://sysoev.ru>
date Mon, 30 Mar 2009 00:00:00 +0400
parents c8cfb6c462ef
children 43cc6f0b77ce
comparison
equal deleted inserted replaced
467:d46142e61c30 468:56baf312c1b5
10 #include <ngx_channel.h> 10 #include <ngx_channel.h>
11 11
12 12
13 static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, 13 static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n,
14 ngx_int_t type); 14 ngx_int_t type);
15 static void ngx_start_cleaner_process(ngx_cycle_t *cycle, ngx_int_t type); 15 static void ngx_start_cache_manager_process(ngx_cycle_t *cycle, ngx_int_t type);
16 static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo); 16 static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo);
17 static ngx_uint_t ngx_reap_children(ngx_cycle_t *cycle); 17 static ngx_uint_t ngx_reap_children(ngx_cycle_t *cycle);
18 static void ngx_master_process_exit(ngx_cycle_t *cycle); 18 static void ngx_master_process_exit(ngx_cycle_t *cycle);
19 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data); 19 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data);
20 static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority); 20 static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority);
22 static void ngx_channel_handler(ngx_event_t *ev); 22 static void ngx_channel_handler(ngx_event_t *ev);
23 #if (NGX_THREADS) 23 #if (NGX_THREADS)
24 static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle); 24 static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle);
25 static ngx_thread_value_t ngx_worker_thread_cycle(void *data); 25 static ngx_thread_value_t ngx_worker_thread_cycle(void *data);
26 #endif 26 #endif
27 static void ngx_cleaner_process_cycle(ngx_cycle_t *cycle, void *data); 27 static void ngx_cache_manager_process_cycle(ngx_cycle_t *cycle, void *data);
28 static void ngx_cleaner_process_handler(ngx_event_t *ev); 28 static void ngx_cache_manager_process_handler(ngx_event_t *ev);
29 29
30 30
31 ngx_uint_t ngx_process; 31 ngx_uint_t ngx_process;
32 ngx_pid_t ngx_pid; 32 ngx_pid_t ngx_pid;
33 ngx_uint_t ngx_threaded; 33 ngx_uint_t ngx_threaded;
120 120
121 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); 121 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
122 122
123 ngx_start_worker_processes(cycle, ccf->worker_processes, 123 ngx_start_worker_processes(cycle, ccf->worker_processes,
124 NGX_PROCESS_RESPAWN); 124 NGX_PROCESS_RESPAWN);
125 ngx_start_cleaner_process(cycle, NGX_PROCESS_RESPAWN); 125 ngx_start_cache_manager_process(cycle, NGX_PROCESS_RESPAWN);
126 126
127 ngx_new_binary = 0; 127 ngx_new_binary = 0;
128 delay = 0; 128 delay = 0;
129 live = 1; 129 live = 1;
130 130
201 ngx_reconfigure = 0; 201 ngx_reconfigure = 0;
202 202
203 if (ngx_new_binary) { 203 if (ngx_new_binary) {
204 ngx_start_worker_processes(cycle, ccf->worker_processes, 204 ngx_start_worker_processes(cycle, ccf->worker_processes,
205 NGX_PROCESS_RESPAWN); 205 NGX_PROCESS_RESPAWN);
206 ngx_start_cleaner_process(cycle, NGX_PROCESS_RESPAWN); 206 ngx_start_cache_manager_process(cycle, NGX_PROCESS_RESPAWN);
207 ngx_noaccepting = 0; 207 ngx_noaccepting = 0;
208 208
209 continue; 209 continue;
210 } 210 }
211 211
220 ngx_cycle = cycle; 220 ngx_cycle = cycle;
221 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, 221 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx,
222 ngx_core_module); 222 ngx_core_module);
223 ngx_start_worker_processes(cycle, ccf->worker_processes, 223 ngx_start_worker_processes(cycle, ccf->worker_processes,
224 NGX_PROCESS_JUST_RESPAWN); 224 NGX_PROCESS_JUST_RESPAWN);
225 ngx_start_cleaner_process(cycle, NGX_PROCESS_JUST_RESPAWN); 225 ngx_start_cache_manager_process(cycle, NGX_PROCESS_JUST_RESPAWN);
226 live = 1; 226 live = 1;
227 ngx_signal_worker_processes(cycle, 227 ngx_signal_worker_processes(cycle,
228 ngx_signal_value(NGX_SHUTDOWN_SIGNAL)); 228 ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
229 } 229 }
230 230
231 if (ngx_restart) { 231 if (ngx_restart) {
232 ngx_restart = 0; 232 ngx_restart = 0;
233 ngx_start_worker_processes(cycle, ccf->worker_processes, 233 ngx_start_worker_processes(cycle, ccf->worker_processes,
234 NGX_PROCESS_RESPAWN); 234 NGX_PROCESS_RESPAWN);
235 ngx_start_cleaner_process(cycle, NGX_PROCESS_RESPAWN); 235 ngx_start_cache_manager_process(cycle, NGX_PROCESS_RESPAWN);
236 live = 1; 236 live = 1;
237 } 237 }
238 238
239 if (ngx_reopen) { 239 if (ngx_reopen) {
240 ngx_reopen = 0; 240 ngx_reopen = 0;
358 } 358 }
359 } 359 }
360 360
361 361
362 static void 362 static void
363 ngx_start_cleaner_process(ngx_cycle_t *cycle, ngx_int_t type) 363 ngx_start_cache_manager_process(ngx_cycle_t *cycle, ngx_int_t type)
364 { 364 {
365 ngx_int_t i; 365 ngx_int_t i;
366 ngx_uint_t n; 366 ngx_uint_t n;
367 ngx_path_t **path; 367 ngx_path_t **path;
368 ngx_channel_t ch; 368 ngx_channel_t ch;
369 369
370 path = ngx_cycle->pathes.elts; 370 path = ngx_cycle->pathes.elts;
371 for (n = 0; n < ngx_cycle->pathes.nelts; n++) { 371 for (n = 0; n < ngx_cycle->pathes.nelts; n++) {
372 if (path[n]->cleaner) { 372 if (path[n]->manager) {
373 goto start; 373 goto start;
374 } 374 }
375 } 375 }
376 376
377 return; 377 return;
378 378
379 start: 379 start:
380 380
381 ch.command = NGX_CMD_OPEN_CHANNEL; 381 ch.command = NGX_CMD_OPEN_CHANNEL;
382 382
383 ngx_spawn_process(cycle, ngx_cleaner_process_cycle, NULL, 383 ngx_spawn_process(cycle, ngx_cache_manager_process_cycle, NULL,
384 "cleaner process", type); 384 "cache manager process", type);
385 385
386 ch.pid = ngx_processes[ngx_process_slot].pid; 386 ch.pid = ngx_processes[ngx_process_slot].pid;
387 ch.slot = ngx_process_slot; 387 ch.slot = ngx_process_slot;
388 ch.fd = ngx_processes[ngx_process_slot].channel[0]; 388 ch.fd = ngx_processes[ngx_process_slot].channel[0];
389 389
1261 1261
1262 #endif 1262 #endif
1263 1263
1264 1264
1265 static void 1265 static void
1266 ngx_cleaner_process_cycle(ngx_cycle_t *cycle, void *data) 1266 ngx_cache_manager_process_cycle(ngx_cycle_t *cycle, void *data)
1267 { 1267 {
1268 void *ident[4]; 1268 void *ident[4];
1269 ngx_event_t ev; 1269 ngx_event_t ev;
1270 1270
1271 cycle->connection_n = 512; 1271 cycle->connection_n = 512;
1273 ngx_worker_process_init(cycle, 0); 1273 ngx_worker_process_init(cycle, 0);
1274 1274
1275 ngx_close_listening_sockets(cycle); 1275 ngx_close_listening_sockets(cycle);
1276 1276
1277 ngx_memzero(&ev, sizeof(ngx_event_t)); 1277 ngx_memzero(&ev, sizeof(ngx_event_t));
1278 ev.handler = ngx_cleaner_process_handler; 1278 ev.handler = ngx_cache_manager_process_handler;
1279 ev.data = ident; 1279 ev.data = ident;
1280 ev.log = cycle->log; 1280 ev.log = cycle->log;
1281 ident[3] = (void *) -1; 1281 ident[3] = (void *) -1;
1282 1282
1283 ngx_use_accept_mutex = 0; 1283 ngx_use_accept_mutex = 0;
1284 1284
1285 ngx_setproctitle("cleaner process"); 1285 ngx_setproctitle("cache manager process");
1286 1286
1287 ngx_add_timer(&ev, 0); 1287 ngx_add_timer(&ev, 0);
1288 1288
1289 for ( ;; ) { 1289 for ( ;; ) {
1290 1290
1303 } 1303 }
1304 } 1304 }
1305 1305
1306 1306
1307 static void 1307 static void
1308 ngx_cleaner_process_handler(ngx_event_t *ev) 1308 ngx_cache_manager_process_handler(ngx_event_t *ev)
1309 { 1309 {
1310 time_t next, n; 1310 time_t next, n;
1311 ngx_uint_t i; 1311 ngx_uint_t i;
1312 ngx_path_t **path; 1312 ngx_path_t **path;
1313 1313
1314 next = 60 * 60; 1314 next = 60 * 60;
1315 1315
1316 path = ngx_cycle->pathes.elts; 1316 path = ngx_cycle->pathes.elts;
1317 for (i = 0; i < ngx_cycle->pathes.nelts; i++) { 1317 for (i = 0; i < ngx_cycle->pathes.nelts; i++) {
1318 1318
1319 if (path[i]->cleaner) { 1319 if (path[i]->manager) {
1320 n = path[i]->cleaner(path[i]->data); 1320 n = path[i]->manager(path[i]->data);
1321 1321
1322 next = (n <= next) ? n : next; 1322 next = (n <= next) ? n : next;
1323 1323
1324 ngx_time_update(0, 0); 1324 ngx_time_update(0, 0);
1325 } 1325 }