Mercurial > hg > nginx-ranges
comparison src/os/unix/ngx_process_cycle.c @ 106:45f7329b4bd0 NGINX_0_3_0
nginx 0.3.0
*) Change: the 10-days live time limit of worker process was
eliminated. The limit was introduced because of millisecond timers
overflow.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Fri, 07 Oct 2005 00:00:00 +0400 |
parents | 45945fa8b8ba |
children | cf3d6edb3ad6 |
comparison
equal
deleted
inserted
replaced
105:531d62c2a28d | 106:45f7329b4bd0 |
---|---|
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; |
34 | 34 |
35 sig_atomic_t ngx_reap; | 35 sig_atomic_t ngx_reap; |
36 sig_atomic_t ngx_timer; | |
37 sig_atomic_t ngx_sigio; | 36 sig_atomic_t ngx_sigio; |
38 sig_atomic_t ngx_terminate; | 37 sig_atomic_t ngx_terminate; |
39 sig_atomic_t ngx_quit; | 38 sig_atomic_t ngx_quit; |
40 sig_atomic_t ngx_debug_quit; | 39 sig_atomic_t ngx_debug_quit; |
41 ngx_uint_t ngx_exiting; | 40 ngx_uint_t ngx_exiting; |
192 cycle->listening.nelts = 0; | 191 cycle->listening.nelts = 0; |
193 | 192 |
194 continue; | 193 continue; |
195 } | 194 } |
196 | 195 |
197 if (ngx_timer) { | |
198 ngx_timer = 0; | |
199 | |
200 if (!ngx_noaccepting) { | |
201 ngx_start_worker_processes(cycle, ccf->worker_processes, | |
202 NGX_PROCESS_JUST_RESPAWN); | |
203 ngx_start_garbage_collector(cycle, NGX_PROCESS_JUST_RESPAWN); | |
204 live = 1; | |
205 ngx_signal_worker_processes(cycle, | |
206 ngx_signal_value(NGX_SHUTDOWN_SIGNAL)); | |
207 } | |
208 } | |
209 | |
210 if (ngx_reconfigure) { | 196 if (ngx_reconfigure) { |
211 ngx_reconfigure = 0; | 197 ngx_reconfigure = 0; |
212 | 198 |
213 if (ngx_new_binary) { | 199 if (ngx_new_binary) { |
214 ngx_start_worker_processes(cycle, ccf->worker_processes, | 200 ngx_start_worker_processes(cycle, ccf->worker_processes, |
318 | 304 |
319 | 305 |
320 static void | 306 static void |
321 ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type) | 307 ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type) |
322 { | 308 { |
323 ngx_int_t i; | 309 ngx_int_t i; |
324 ngx_channel_t ch; | 310 ngx_channel_t ch; |
325 struct itimerval itv; | |
326 | 311 |
327 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start worker processes"); | 312 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start worker processes"); |
328 | 313 |
329 ch.command = NGX_CMD_OPEN_CHANNEL; | 314 ch.command = NGX_CMD_OPEN_CHANNEL; |
330 | 315 |
354 /* TODO: NGX_AGAIN */ | 339 /* TODO: NGX_AGAIN */ |
355 | 340 |
356 ngx_write_channel(ngx_processes[i].channel[0], | 341 ngx_write_channel(ngx_processes[i].channel[0], |
357 &ch, sizeof(ngx_channel_t), cycle->log); | 342 &ch, sizeof(ngx_channel_t), cycle->log); |
358 } | 343 } |
359 } | |
360 | |
361 /* | |
362 * we have to limit the maximum life time of the worker processes | |
363 * by 10 days because our millisecond event timer is limited | |
364 * by 24 days on 32-bit platforms | |
365 */ | |
366 | |
367 itv.it_interval.tv_sec = 0; | |
368 itv.it_interval.tv_usec = 0; | |
369 itv.it_value.tv_sec = 10 * 24 * 60 * 60; | |
370 itv.it_value.tv_usec = 0; | |
371 | |
372 if (setitimer(ITIMER_REAL, &itv, NULL) == -1) { | |
373 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
374 "setitimer() failed"); | |
375 } | 344 } |
376 } | 345 } |
377 | 346 |
378 | 347 |
379 static void | 348 static void |
809 { | 778 { |
810 sigset_t set; | 779 sigset_t set; |
811 ngx_int_t n; | 780 ngx_int_t n; |
812 ngx_uint_t i; | 781 ngx_uint_t i; |
813 struct rlimit rlmt; | 782 struct rlimit rlmt; |
814 struct timeval tv; | |
815 ngx_core_conf_t *ccf; | 783 ngx_core_conf_t *ccf; |
816 ngx_listening_t *ls; | 784 ngx_listening_t *ls; |
817 | |
818 ngx_gettimeofday(&tv); | |
819 | |
820 ngx_start_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000 + tv.tv_usec / 1000; | |
821 ngx_old_elapsed_msec = 0; | |
822 ngx_elapsed_msec = 0; | |
823 | |
824 | 785 |
825 ngx_process = NGX_PROCESS_WORKER; | 786 ngx_process = NGX_PROCESS_WORKER; |
826 | 787 |
827 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); | 788 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
828 | 789 |