comparison src/os/unix/ngx_process_cycle.c @ 324:7cf404023f50 NGINX_0_5_32

nginx 0.5.32 *) Change: now nginx tries to set the "worker_priority", "worker_rlimit_nofile", "worker_rlimit_core", and "worker_rlimit_sigpending" without super-user privileges. *) Change: now nginx escapes space and "%" in request to a mail proxy authentication server. *) Change: now nginx escapes "%" in $memcached_key variable. *) Change: the special make target "upgrade1" was defined for online upgrade of 0.1.x versions. *) Feature: the "add_header Last-Modified ..." directive changes the "Last-Modified" response header line. *) Feature: the mail proxy supports AUTHENTICATE in IMAP mode. Thanks to Maxim Dounin. *) Feature: the mail proxy supports STARTTLS in SMTP mode. Thanks to Maxim Dounin. *) Bugfix: nginx did not close directory file on HEAD request if autoindex was used. Thanks to Arkadiusz Patyk. *) Bugfix: the "proxy_hide_header" and "fastcgi_hide_header" directives did not hide response header lines whose name was longer than 32 characters. Thanks to Manlio Perillo. *) Bugfix: active connection counter always increased if mail proxy was used. *) Bugfix: if backend returned response header only using non-buffered proxy, then nginx closed backend connection on timeout. *) Bugfix: nginx did not support several "Connection" request header lines. *) Bugfix: a charset set by the "charset" directive was not appended to the "Content-Type" header set by $r->send_http_header(). *) Bugfix: a segmentation fault might occur in worker process if /dev/poll method was used. *) Bugfix: nginx did not work on FreeBSD/sparc64. *) Bugfix: a segmentation fault occurred in worker process if invalid address was set in the "auth_http" directive. *) Bugfix: now nginx uses default listen backlog value 511 on all platforms except FreeBSD. Thanks to Jiang Hong. *) Bugfix: now Solaris sendfilev() is not used to transfer the client request body to FastCGI-server via the unix domain socket. *) Bugfix: if the same host without specified port was used as backend for HTTP and HTTPS, then nginx used only one port - 80 or 443. *) Bugfix: the "proxy_ignore_client_abort" and "fastcgi_ignore_client_abort" directives did not work; bug appeared in 0.5.13.
author Igor Sysoev <http://sysoev.ru>
date Mon, 24 Sep 2007 00:00:00 +0400
parents f745bf973510
children 26ff8d6b618d
comparison
equal deleted inserted replaced
323:85aeb2da6e4c 324:7cf404023f50
60 60
61 u_long cpu_affinity; 61 u_long cpu_affinity;
62 static u_char master_process[] = "master process"; 62 static u_char master_process[] = "master process";
63 63
64 64
65 static ngx_cycle_t ngx_exit_cycle;
66 static ngx_log_t ngx_exit_log;
67 static ngx_open_file_t ngx_exit_log_file;
68
69
65 void 70 void
66 ngx_master_process_cycle(ngx_cycle_t *cycle) 71 ngx_master_process_cycle(ngx_cycle_t *cycle)
67 { 72 {
68 char *title; 73 char *title;
69 u_char *p; 74 u_char *p;
647 ngx_modules[i]->exit_master(cycle); 652 ngx_modules[i]->exit_master(cycle);
648 } 653 }
649 } 654 }
650 655
651 /* 656 /*
652 * we do not destroy cycle->pool here because a signal handler 657 * Copy ngx_cycle->log related data to the special static exit cycle,
653 * that uses cycle->log can be called at this point 658 * log, and log file structures enough to allow a signal handler to log.
659 * The handler may be called when standard ngx_cycle->log allocated from
660 * ngx_cycle->pool is already destroyed.
654 */ 661 */
655 662
656 #if 0 663 ngx_exit_log_file.fd = ngx_cycle->log->file->fd;
664
665 ngx_exit_log = *ngx_cycle->log;
666 ngx_exit_log.file = &ngx_exit_log_file;
667
668 ngx_exit_cycle.log = &ngx_exit_log;
669 ngx_cycle = &ngx_exit_cycle;
670
657 ngx_destroy_pool(cycle->pool); 671 ngx_destroy_pool(cycle->pool);
658 #endif
659 672
660 exit(0); 673 exit(0);
661 } 674 }
662 675
663 676
790 exit(2); 803 exit(2);
791 } 804 }
792 805
793 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); 806 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
794 807
808 if (priority && ccf->priority != 0) {
809 if (setpriority(PRIO_PROCESS, 0, ccf->priority) == -1) {
810 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
811 "setpriority(%d) failed", ccf->priority);
812 }
813 }
814
815 if (ccf->rlimit_nofile != NGX_CONF_UNSET) {
816 rlmt.rlim_cur = (rlim_t) ccf->rlimit_nofile;
817 rlmt.rlim_max = (rlim_t) ccf->rlimit_nofile;
818
819 if (setrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
820 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
821 "setrlimit(RLIMIT_NOFILE, %i) failed",
822 ccf->rlimit_nofile);
823 }
824 }
825
826 if (ccf->rlimit_core != NGX_CONF_UNSET_SIZE) {
827 rlmt.rlim_cur = (rlim_t) ccf->rlimit_core;
828 rlmt.rlim_max = (rlim_t) ccf->rlimit_core;
829
830 if (setrlimit(RLIMIT_CORE, &rlmt) == -1) {
831 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
832 "setrlimit(RLIMIT_CORE, %i) failed",
833 ccf->rlimit_core);
834 }
835 }
836
837 #ifdef RLIMIT_SIGPENDING
838 if (ccf->rlimit_sigpending != NGX_CONF_UNSET) {
839 rlmt.rlim_cur = (rlim_t) ccf->rlimit_sigpending;
840 rlmt.rlim_max = (rlim_t) ccf->rlimit_sigpending;
841
842 if (setrlimit(RLIMIT_SIGPENDING, &rlmt) == -1) {
843 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
844 "setrlimit(RLIMIT_SIGPENDING, %i) failed",
845 ccf->rlimit_sigpending);
846 }
847 }
848 #endif
849
795 if (geteuid() == 0) { 850 if (geteuid() == 0) {
796 if (priority && ccf->priority != 0) {
797 if (setpriority(PRIO_PROCESS, 0, ccf->priority) == -1) {
798 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
799 "setpriority(%d) failed", ccf->priority);
800 }
801 }
802
803 if (ccf->rlimit_nofile != NGX_CONF_UNSET) {
804 rlmt.rlim_cur = (rlim_t) ccf->rlimit_nofile;
805 rlmt.rlim_max = (rlim_t) ccf->rlimit_nofile;
806
807 if (setrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
808 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
809 "setrlimit(RLIMIT_NOFILE, %i) failed",
810 ccf->rlimit_nofile);
811 }
812 }
813
814 if (ccf->rlimit_core != NGX_CONF_UNSET_SIZE) {
815 rlmt.rlim_cur = (rlim_t) ccf->rlimit_core;
816 rlmt.rlim_max = (rlim_t) ccf->rlimit_core;
817
818 if (setrlimit(RLIMIT_CORE, &rlmt) == -1) {
819 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
820 "setrlimit(RLIMIT_CORE, %i) failed",
821 ccf->rlimit_core);
822 }
823 }
824
825 #ifdef RLIMIT_SIGPENDING
826 if (ccf->rlimit_sigpending != NGX_CONF_UNSET) {
827 rlmt.rlim_cur = (rlim_t) ccf->rlimit_sigpending;
828 rlmt.rlim_max = (rlim_t) ccf->rlimit_sigpending;
829
830 if (setrlimit(RLIMIT_SIGPENDING, &rlmt) == -1) {
831 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
832 "setrlimit(RLIMIT_SIGPENDING, %i) failed",
833 ccf->rlimit_sigpending);
834 }
835 }
836 #endif
837
838 if (setgid(ccf->group) == -1) { 851 if (setgid(ccf->group) == -1) {
839 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, 852 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
840 "setgid(%d) failed", ccf->group); 853 "setgid(%d) failed", ccf->group);
841 /* fatal */ 854 /* fatal */
842 exit(2); 855 exit(2);
994 ngx_debug_point(); 1007 ngx_debug_point();
995 } 1008 }
996 } 1009 }
997 1010
998 /* 1011 /*
999 * we do not destroy cycle->pool here because a signal handler 1012 * Copy ngx_cycle->log related data to the special static exit cycle,
1000 * that uses cycle->log can be called at this point 1013 * log, and log file structures enough to allow a signal handler to log.
1014 * The handler may be called when standard ngx_cycle->log allocated from
1015 * ngx_cycle->pool is already destroyed.
1001 */ 1016 */
1002 1017
1003 #if 0 1018 ngx_exit_log_file.fd = ngx_cycle->log->file->fd;
1019
1020 ngx_exit_log = *ngx_cycle->log;
1021 ngx_exit_log.file = &ngx_exit_log_file;
1022
1023 ngx_exit_cycle.log = &ngx_exit_log;
1024 ngx_cycle = &ngx_exit_cycle;
1025
1004 ngx_destroy_pool(cycle->pool); 1026 ngx_destroy_pool(cycle->pool);
1005 #endif 1027
1028 ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0, "exit");
1006 1029
1007 exit(0); 1030 exit(0);
1008 } 1031 }
1009 1032
1010 1033