Mercurial > hg > nginx-quic
comparison src/os/unix/ngx_process_cycle.c @ 501:d4ea69372b94 release-0.1.25
nginx-0.1.25-RELEASE import
*) Bugfix: nginx did run on Linux parisc.
*) Feature: nginx now does not start under FreeBSD if the sysctl
kern.ipc.somaxconn value is too big.
*) Bugfix: if a request was internally redirected by the
ngx_http_index_module module to the ngx_http_proxy_module or
ngx_http_fastcgi_module modules, then the index file was not closed
after request completion.
*) Feature: the "proxy_pass" can be used in location with regular
expression.
*) Feature: the ngx_http_rewrite_filter_module module supports the
condition like "if ($HTTP_USER_AGENT ~ MSIE)".
*) Bugfix: nginx started too slow if the large number of addresses and
text values were used in the "geo" directive.
*) Change: a variable name must be declared as "$name" in the "geo"
directive. The previous variant without "$" is still supported, but
will be removed soon.
*) Feature: the "%{VARIABLE}v" logging parameter.
*) Feature: the "set $name value" directive.
*) Bugfix: gcc 4.0 compatibility.
*) Feature: the --with-openssl-opt=OPTIONS autoconfiguration directive.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sat, 19 Mar 2005 12:38:37 +0000 |
parents | c52408583801 |
children | ee66921ecd47 |
comparison
equal
deleted
inserted
replaced
500:9a0f304470f5 | 501:d4ea69372b94 |
---|---|
9 #include <ngx_event.h> | 9 #include <ngx_event.h> |
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_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type); | 15 static void ngx_start_garbage_collector(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_childs(ngx_cycle_t *cycle); | 17 static ngx_uint_t ngx_reap_childs(ngx_cycle_t *cycle); |
18 static void ngx_master_exit(ngx_cycle_t *cycle); | 18 static void ngx_master_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); |
21 static void ngx_channel_handler(ngx_event_t *ev); | 21 static void ngx_channel_handler(ngx_event_t *ev); |
22 #if (NGX_THREADS) | 22 #if (NGX_THREADS) |
23 static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle); | 23 static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle); |
24 static void *ngx_worker_thread_cycle(void *data); | 24 static void *ngx_worker_thread_cycle(void *data); |
25 #endif | 25 #endif |
26 #if 0 | |
26 static void ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data); | 27 static void ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data); |
28 #endif | |
27 | 29 |
28 | 30 |
29 ngx_uint_t ngx_process; | 31 ngx_uint_t ngx_process; |
30 ngx_pid_t ngx_pid; | 32 ngx_pid_t ngx_pid; |
31 ngx_uint_t ngx_threaded; | 33 ngx_uint_t ngx_threaded; |
57 | 59 |
58 | 60 |
59 u_char master_process[] = "master process"; | 61 u_char master_process[] = "master process"; |
60 | 62 |
61 | 63 |
62 void ngx_master_process_cycle(ngx_cycle_t *cycle) | 64 void |
65 ngx_master_process_cycle(ngx_cycle_t *cycle) | |
63 { | 66 { |
64 char *title; | 67 char *title; |
65 u_char *p; | 68 u_char *p; |
66 size_t size; | 69 size_t size; |
67 ngx_int_t i; | 70 ngx_int_t i; |
252 } | 255 } |
253 } | 256 } |
254 } | 257 } |
255 | 258 |
256 | 259 |
257 void ngx_single_process_cycle(ngx_cycle_t *cycle) | 260 void |
261 ngx_single_process_cycle(ngx_cycle_t *cycle) | |
258 { | 262 { |
259 ngx_uint_t i; | 263 ngx_uint_t i; |
260 | 264 |
261 ngx_init_temp_number(); | 265 ngx_init_temp_number(); |
262 | 266 |
298 } | 302 } |
299 } | 303 } |
300 } | 304 } |
301 | 305 |
302 | 306 |
303 static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, | 307 static void |
304 ngx_int_t type) | 308 ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type) |
305 { | 309 { |
306 ngx_int_t i; | 310 ngx_int_t i; |
307 ngx_channel_t ch; | 311 ngx_channel_t ch; |
308 struct itimerval itv; | 312 struct itimerval itv; |
309 | 313 |
357 "setitimer() failed"); | 361 "setitimer() failed"); |
358 } | 362 } |
359 } | 363 } |
360 | 364 |
361 | 365 |
362 static void ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type) | 366 static void |
363 { | 367 ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type) |
364 ngx_int_t i; | 368 { |
365 ngx_channel_t ch; | 369 #if 0 |
366 | 370 ngx_int_t i; |
367 return; | 371 ngx_channel_t ch; |
368 | 372 |
369 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start garbage collector"); | 373 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start garbage collector"); |
370 | 374 |
371 ch.command = NGX_CMD_OPEN_CHANNEL; | 375 ch.command = NGX_CMD_OPEN_CHANNEL; |
372 | 376 |
395 /* TODO: NGX_AGAIN */ | 399 /* TODO: NGX_AGAIN */ |
396 | 400 |
397 ngx_write_channel(ngx_processes[i].channel[0], | 401 ngx_write_channel(ngx_processes[i].channel[0], |
398 &ch, sizeof(ngx_channel_t), cycle->log); | 402 &ch, sizeof(ngx_channel_t), cycle->log); |
399 } | 403 } |
400 } | 404 #endif |
401 | 405 } |
402 | 406 |
403 static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo) | 407 |
408 static void | |
409 ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo) | |
404 { | 410 { |
405 ngx_int_t i; | 411 ngx_int_t i; |
406 ngx_err_t err; | 412 ngx_err_t err; |
407 ngx_channel_t ch; | 413 ngx_channel_t ch; |
408 | |
409 | 414 |
410 switch (signo) { | 415 switch (signo) { |
411 | 416 |
412 case ngx_signal_value(NGX_SHUTDOWN_SIGNAL): | 417 case ngx_signal_value(NGX_SHUTDOWN_SIGNAL): |
413 ch.command = NGX_CMD_QUIT; | 418 ch.command = NGX_CMD_QUIT; |
490 } | 495 } |
491 } | 496 } |
492 } | 497 } |
493 | 498 |
494 | 499 |
495 static ngx_uint_t ngx_reap_childs(ngx_cycle_t *cycle) | 500 static ngx_uint_t |
501 ngx_reap_childs(ngx_cycle_t *cycle) | |
496 { | 502 { |
497 ngx_int_t i, n; | 503 ngx_int_t i, n; |
498 ngx_uint_t live; | 504 ngx_uint_t live; |
499 ngx_channel_t ch; | 505 ngx_channel_t ch; |
500 | 506 |
617 | 623 |
618 return live; | 624 return live; |
619 } | 625 } |
620 | 626 |
621 | 627 |
622 static void ngx_master_exit(ngx_cycle_t *cycle) | 628 static void |
629 ngx_master_exit(ngx_cycle_t *cycle) | |
623 { | 630 { |
624 ngx_delete_pidfile(cycle); | 631 ngx_delete_pidfile(cycle); |
625 | 632 |
626 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exit"); | 633 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exit"); |
627 | 634 |
629 | 636 |
630 exit(0); | 637 exit(0); |
631 } | 638 } |
632 | 639 |
633 | 640 |
634 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) | 641 static void |
635 { | 642 ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) |
643 { | |
644 #if (NGX_THREADS) | |
636 ngx_int_t n; | 645 ngx_int_t n; |
637 ngx_err_t err; | 646 ngx_err_t err; |
638 ngx_core_conf_t *ccf; | 647 ngx_core_conf_t *ccf; |
648 #endif | |
639 | 649 |
640 ngx_worker_process_init(cycle, 1); | 650 ngx_worker_process_init(cycle, 1); |
641 | 651 |
642 ngx_setproctitle("worker process"); | 652 ngx_setproctitle("worker process"); |
643 | 653 |
666 exit(2); | 676 exit(2); |
667 } | 677 } |
668 | 678 |
669 for (n = 0; n < ngx_threads_n; n++) { | 679 for (n = 0; n < ngx_threads_n; n++) { |
670 | 680 |
671 if (!(ngx_threads[n].cv = ngx_cond_init(cycle->log))) { | 681 ngx_threads[n].cv = ngx_cond_init(cycle->log); |
682 | |
683 if (ngx_threads[n].cv == NULL) { | |
672 /* fatal */ | 684 /* fatal */ |
673 exit(2); | 685 exit(2); |
674 } | 686 } |
675 | 687 |
676 if (ngx_create_thread((ngx_tid_t *) &ngx_threads[n].tid, | 688 if (ngx_create_thread((ngx_tid_t *) &ngx_threads[n].tid, |
746 } | 758 } |
747 } | 759 } |
748 } | 760 } |
749 | 761 |
750 | 762 |
751 static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority) | 763 static void |
764 ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority) | |
752 { | 765 { |
753 sigset_t set; | 766 sigset_t set; |
754 ngx_int_t n; | 767 ngx_int_t n; |
755 ngx_uint_t i; | 768 ngx_uint_t i; |
756 struct timeval tv; | 769 struct timeval tv; |
871 exit(2); | 884 exit(2); |
872 } | 885 } |
873 } | 886 } |
874 | 887 |
875 | 888 |
876 static void ngx_channel_handler(ngx_event_t *ev) | 889 static void |
890 ngx_channel_handler(ngx_event_t *ev) | |
877 { | 891 { |
878 ngx_int_t n; | 892 ngx_int_t n; |
879 ngx_channel_t ch; | 893 ngx_channel_t ch; |
880 ngx_connection_t *c; | 894 ngx_connection_t *c; |
881 | 895 |
950 } | 964 } |
951 | 965 |
952 | 966 |
953 #if (NGX_THREADS) | 967 #if (NGX_THREADS) |
954 | 968 |
955 static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle) | 969 static void |
970 ngx_wakeup_worker_threads(ngx_cycle_t *cycle) | |
956 { | 971 { |
957 ngx_int_t i; | 972 ngx_int_t i; |
958 ngx_uint_t live; | 973 ngx_uint_t live; |
959 | 974 |
960 for ( ;; ) { | 975 for ( ;; ) { |
992 ngx_sched_yield(); | 1007 ngx_sched_yield(); |
993 } | 1008 } |
994 } | 1009 } |
995 | 1010 |
996 | 1011 |
997 static void *ngx_worker_thread_cycle(void *data) | 1012 static void * |
1013 ngx_worker_thread_cycle(void *data) | |
998 { | 1014 { |
999 ngx_thread_t *thr = data; | 1015 ngx_thread_t *thr = data; |
1000 | 1016 |
1001 sigset_t set; | 1017 sigset_t set; |
1002 ngx_err_t err; | 1018 ngx_err_t err; |
1020 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0, | 1036 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0, |
1021 "thread " NGX_TID_T_FMT " started", ngx_thread_self()); | 1037 "thread " NGX_TID_T_FMT " started", ngx_thread_self()); |
1022 | 1038 |
1023 ngx_setthrtitle("worker thread"); | 1039 ngx_setthrtitle("worker thread"); |
1024 | 1040 |
1025 if (!(tls = ngx_calloc(sizeof(ngx_core_tls_t), cycle->log))) { | 1041 tls = ngx_calloc(sizeof(ngx_core_tls_t), cycle->log); |
1042 if (tls == NULL) { | |
1026 return (void *) 1; | 1043 return (void *) 1; |
1027 } | 1044 } |
1028 | 1045 |
1029 err = ngx_thread_set_tls(ngx_core_tls_key, tls); | 1046 err = ngx_thread_set_tls(ngx_core_tls_key, tls); |
1030 if (err != 0) { | 1047 if (err != 0) { |
1075 } | 1092 } |
1076 | 1093 |
1077 #endif | 1094 #endif |
1078 | 1095 |
1079 | 1096 |
1080 static void ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data) | 1097 #if 0 |
1098 | |
1099 static void | |
1100 ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data) | |
1081 { | 1101 { |
1082 ngx_uint_t i; | 1102 ngx_uint_t i; |
1083 ngx_gc_t ctx; | 1103 ngx_gc_t ctx; |
1084 ngx_path_t **path; | 1104 ngx_path_t **path; |
1085 ngx_event_t *ev; | 1105 ngx_event_t *ev; |
1121 ngx_add_timer(ev, 60 * 60 * 1000); | 1141 ngx_add_timer(ev, 60 * 60 * 1000); |
1122 | 1142 |
1123 ngx_process_events(cycle); | 1143 ngx_process_events(cycle); |
1124 } | 1144 } |
1125 } | 1145 } |
1146 | |
1147 #endif |