comparison src/os/unix/ngx_process_cycle.c @ 328:390b8f8309d6 NGINX_0_6_8

nginx 0.6.8 *) 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. *) Bugfix: nginx used path relative to configuration prefix for non-absolute configuration file path specified in the "-c" key; bug appeared in 0.6.6. *) Bugfix: nginx did not work on FreeBSD/sparc64.
author Igor Sysoev <http://sysoev.ru>
date Mon, 20 Aug 2007 00:00:00 +0400
parents f745bf973510
children 3a91bfeffaba
comparison
equal deleted inserted replaced
327:be18d26e067c 328:390b8f8309d6
790 exit(2); 790 exit(2);
791 } 791 }
792 792
793 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); 793 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
794 794
795 if (priority && ccf->priority != 0) {
796 if (setpriority(PRIO_PROCESS, 0, ccf->priority) == -1) {
797 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
798 "setpriority(%d) failed", ccf->priority);
799 }
800 }
801
802 if (ccf->rlimit_nofile != NGX_CONF_UNSET) {
803 rlmt.rlim_cur = (rlim_t) ccf->rlimit_nofile;
804 rlmt.rlim_max = (rlim_t) ccf->rlimit_nofile;
805
806 if (setrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
807 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
808 "setrlimit(RLIMIT_NOFILE, %i) failed",
809 ccf->rlimit_nofile);
810 }
811 }
812
813 if (ccf->rlimit_core != NGX_CONF_UNSET_SIZE) {
814 rlmt.rlim_cur = (rlim_t) ccf->rlimit_core;
815 rlmt.rlim_max = (rlim_t) ccf->rlimit_core;
816
817 if (setrlimit(RLIMIT_CORE, &rlmt) == -1) {
818 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
819 "setrlimit(RLIMIT_CORE, %i) failed",
820 ccf->rlimit_core);
821 }
822 }
823
824 #ifdef RLIMIT_SIGPENDING
825 if (ccf->rlimit_sigpending != NGX_CONF_UNSET) {
826 rlmt.rlim_cur = (rlim_t) ccf->rlimit_sigpending;
827 rlmt.rlim_max = (rlim_t) ccf->rlimit_sigpending;
828
829 if (setrlimit(RLIMIT_SIGPENDING, &rlmt) == -1) {
830 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
831 "setrlimit(RLIMIT_SIGPENDING, %i) failed",
832 ccf->rlimit_sigpending);
833 }
834 }
835 #endif
836
795 if (geteuid() == 0) { 837 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) { 838 if (setgid(ccf->group) == -1) {
839 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, 839 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
840 "setgid(%d) failed", ccf->group); 840 "setgid(%d) failed", ccf->group);
841 /* fatal */ 841 /* fatal */
842 exit(2); 842 exit(2);