comparison src/os/unix/ngx_process_cycle.c @ 22:8b6db3bda591 NGINX_0_1_11

nginx 0.1.11 *) Feature: the worker_priority directive. *) Change: both tcp_nopush and tcp_nodelay directives affect the transferred response. *) Bugfix: nginx did not call initgroups(). Thanks to Andrew Sitnikov and Andrei Nigmatulin. *) Change: now the ngx_http_autoindex_module shows the file size in the bytes. *) Bugfix: the ngx_http_autoindex_module returned the 500 error if the broken symlink was in a directory. *) Bugfix: the files bigger than 4G could not be transferred using sendfile. *) Bugfix: if the backend was resolved to several backends and there was an error while the response waiting then process may got caught in an endless loop. *) Bugfix: the worker process may exit with the "unknown cycle" message when the /dev/poll method was used. *) Bugfix: "close() channel failed" errors. *) Bugfix: the autodetection of the "nobody" and "nogroup" groups. *) Bugfix: the send_lowat directive did not work on Linux. *) Bugfix: the segmentation fault occurred if there was no events section in configuration. *) Bugfix: nginx could not be built on OpenBSD. *) Bugfix: the double slashes in "://" in the URI were converted to ":/".
author Igor Sysoev <http://sysoev.ru>
date Thu, 02 Dec 2004 00:00:00 +0300
parents 6f8b0dc0f8dd
children 45fe5b98a9de
comparison
equal deleted inserted replaced
21:4eeb9cfef970 22:8b6db3bda591
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);
20 static void ngx_worker_process_init(ngx_cycle_t *cycle); 20 static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority);
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
562 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, 562 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
563 "can not respawn %s", ngx_processes[i].name); 563 "can not respawn %s", ngx_processes[i].name);
564 continue; 564 continue;
565 } 565 }
566 566
567
568 ch.command = NGX_CMD_OPEN_CHANNEL;
569 ch.pid = ngx_processes[ngx_process_slot].pid;
570 ch.slot = ngx_process_slot;
571 ch.fd = ngx_processes[ngx_process_slot].channel[0];
572
573 for (n = 0; n < ngx_last_process; n++) {
574
575 if (n == ngx_process_slot
576 || ngx_processes[n].pid == -1
577 || ngx_processes[n].channel[0] == -1)
578 {
579 continue;
580 }
581
582 ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0,
583 "pass channel s:%d pid:%P fd:%d to s:%i pid:%P fd:%d",
584 ch.slot, ch.pid, ch.fd,
585 n, ngx_processes[n].pid,
586 ngx_processes[n].channel[0]);
587
588 /* TODO: NGX_AGAIN */
589
590 ngx_write_channel(ngx_processes[n].channel[0],
591 &ch, sizeof(ngx_channel_t), cycle->log);
592 }
593
567 live = 1; 594 live = 1;
568 595
569 continue; 596 continue;
570 } 597 }
571 598
609 { 636 {
610 ngx_int_t n; 637 ngx_int_t n;
611 ngx_err_t err; 638 ngx_err_t err;
612 ngx_core_conf_t *ccf; 639 ngx_core_conf_t *ccf;
613 640
614 ngx_worker_process_init(cycle); 641 ngx_worker_process_init(cycle, 1);
615 642
616 ngx_setproctitle("worker process"); 643 ngx_setproctitle("worker process");
617 644
618 #if (NGX_THREADS) 645 #if (NGX_THREADS)
619 646
716 } 743 }
717 } 744 }
718 } 745 }
719 746
720 747
721 static void ngx_worker_process_init(ngx_cycle_t *cycle) 748 static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
722 { 749 {
723 sigset_t set; 750 sigset_t set;
724 ngx_int_t n; 751 ngx_int_t n;
725 ngx_uint_t i; 752 ngx_uint_t i;
726 struct timeval tv; 753 struct timeval tv;
737 ngx_process = NGX_PROCESS_WORKER; 764 ngx_process = NGX_PROCESS_WORKER;
738 765
739 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); 766 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
740 767
741 if (geteuid() == 0) { 768 if (geteuid() == 0) {
769 if (priority && ccf->priority != 0) {
770 if (setpriority(PRIO_PROCESS, 0, ccf->priority) == -1) {
771 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
772 "setpriority(%d) failed", ccf->priority);
773 }
774 }
775
742 if (setgid(ccf->group) == -1) { 776 if (setgid(ccf->group) == -1) {
743 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, 777 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
744 "setgid(%d) failed", ccf->group); 778 "setgid(%d) failed", ccf->group);
745 /* fatal */ 779 /* fatal */
746 exit(2); 780 exit(2);
781 }
782
783 if (initgroups(ccf->username, ccf->group) == -1) {
784 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
785 "initgroups(%s, %d) failed",
786 ccf->username, ccf->group);
747 } 787 }
748 788
749 if (setuid(ccf->user) == -1) { 789 if (setuid(ccf->user) == -1) {
750 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, 790 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
751 "setuid(%d) failed", ccf->user); 791 "setuid(%d) failed", ccf->user);
1039 ngx_uint_t i; 1079 ngx_uint_t i;
1040 ngx_gc_t ctx; 1080 ngx_gc_t ctx;
1041 ngx_path_t **path; 1081 ngx_path_t **path;
1042 ngx_event_t *ev; 1082 ngx_event_t *ev;
1043 1083
1044 ngx_worker_process_init(cycle); 1084 ngx_worker_process_init(cycle, 0);
1045 1085
1046 ev = &cycle->read_events[ngx_channel]; 1086 ev = &cycle->read_events[ngx_channel];
1047 1087
1048 ngx_accept_mutex = NULL; 1088 ngx_accept_mutex = NULL;
1049 1089