Mercurial > hg > nginx
comparison src/os/win32/ngx_process_cycle.c @ 2922:f0604d0b28a6
*) exit if no workers could not be started
*) do not quit old workers if no new workers could not be started
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sat, 06 Jun 2009 12:36:44 +0000 |
parents | e7278e647f1a |
children | 7b68caedea01 |
comparison
equal
deleted
inserted
replaced
2921:e7278e647f1a | 2922:f0604d0b28a6 |
---|---|
12 | 12 |
13 static void ngx_process_init(ngx_cycle_t *cycle); | 13 static void ngx_process_init(ngx_cycle_t *cycle); |
14 static void ngx_console_init(ngx_cycle_t *cycle); | 14 static void ngx_console_init(ngx_cycle_t *cycle); |
15 static int __stdcall ngx_console_handler(u_long type); | 15 static int __stdcall ngx_console_handler(u_long type); |
16 static ngx_int_t ngx_create_events(ngx_cycle_t *cycle); | 16 static ngx_int_t ngx_create_events(ngx_cycle_t *cycle); |
17 static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t type); | 17 static ngx_int_t ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t type); |
18 static void ngx_reopen_worker_processes(ngx_cycle_t *cycle); | 18 static void ngx_reopen_worker_processes(ngx_cycle_t *cycle); |
19 static void ngx_quit_worker_processes(ngx_cycle_t *cycle, ngx_uint_t old); | 19 static void ngx_quit_worker_processes(ngx_cycle_t *cycle, ngx_uint_t old); |
20 static void ngx_terminate_worker_processes(ngx_cycle_t *cycle); | 20 static void ngx_terminate_worker_processes(ngx_cycle_t *cycle); |
21 static ngx_uint_t ngx_reap_worker(ngx_cycle_t *cycle, HANDLE h); | 21 static ngx_uint_t ngx_reap_worker(ngx_cycle_t *cycle, HANDLE h); |
22 static void ngx_master_process_exit(ngx_cycle_t *cycle); | 22 static void ngx_master_process_exit(ngx_cycle_t *cycle); |
114 events[2] = ngx_reopen_event; | 114 events[2] = ngx_reopen_event; |
115 events[3] = ngx_reload_event; | 115 events[3] = ngx_reload_event; |
116 | 116 |
117 ngx_close_listening_sockets(cycle); | 117 ngx_close_listening_sockets(cycle); |
118 | 118 |
119 ngx_start_worker_processes(cycle, NGX_PROCESS_RESPAWN); | 119 if (ngx_start_worker_processes(cycle, NGX_PROCESS_RESPAWN) == 0) { |
120 exit(2); | |
121 } | |
120 | 122 |
121 timer = 0; | 123 timer = 0; |
122 timeout = INFINITE; | 124 timeout = INFINITE; |
123 | 125 |
124 for ( ;; ) { | 126 for ( ;; ) { |
204 continue; | 206 continue; |
205 } | 207 } |
206 | 208 |
207 ngx_cycle = cycle; | 209 ngx_cycle = cycle; |
208 | 210 |
209 ngx_start_worker_processes(cycle, NGX_PROCESS_JUST_RESPAWN); | 211 if (ngx_start_worker_processes(cycle, NGX_PROCESS_JUST_RESPAWN)) { |
210 ngx_quit_worker_processes(cycle, 1); | 212 ngx_quit_worker_processes(cycle, 1); |
213 } | |
211 | 214 |
212 continue; | 215 continue; |
213 } | 216 } |
214 | 217 |
215 if (ev > WAIT_OBJECT_0 + 3 && ev < WAIT_OBJECT_0 + nev) { | 218 if (ev > WAIT_OBJECT_0 + 3 && ev < WAIT_OBJECT_0 + nev) { |
380 | 383 |
381 return NGX_OK; | 384 return NGX_OK; |
382 } | 385 } |
383 | 386 |
384 | 387 |
385 static void | 388 static ngx_int_t |
386 ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t type) | 389 ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t type) |
387 { | 390 { |
388 ngx_int_t n; | 391 ngx_int_t n; |
389 ngx_core_conf_t *ccf; | 392 ngx_core_conf_t *ccf; |
390 | 393 |
392 | 395 |
393 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); | 396 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
394 | 397 |
395 for (n = 0; n < ccf->worker_processes; n++) { | 398 for (n = 0; n < ccf->worker_processes; n++) { |
396 if (ngx_spawn_process(cycle, "worker", type) == NGX_INVALID_PID) { | 399 if (ngx_spawn_process(cycle, "worker", type) == NGX_INVALID_PID) { |
397 return; | 400 break; |
398 } | 401 } |
399 } | 402 } |
403 | |
404 return n; | |
400 } | 405 } |
401 | 406 |
402 | 407 |
403 static void | 408 static void |
404 ngx_reopen_worker_processes(ngx_cycle_t *cycle) | 409 ngx_reopen_worker_processes(ngx_cycle_t *cycle) |