comparison src/os/unix/ngx_process_cycle.c @ 290:f745bf973510 NGINX_0_5_15

nginx 0.5.15 *) Feature: the mail proxy supports authenticated SMTP proxying and the "smtp_auth", "smtp_capablities", and "xclient" directives. Thanks to Anton Yuzhaninov and Maxim Dounin. *) Feature: now the keep-alive connections are closed just after receiving the reconfiguration signal. *) Change: the "imap" and "auth" directives were renamed to the "mail" and "pop3_auth" directives. *) Bugfix: a segmentation fault occurred in worker process if the CRAM-MD5 authentication method was used and the APOP method was disabled. *) Bugfix: if the "starttls only" directive was used in POP3 protocol, then nginx allowed authentication without switching to the SSL mode. *) Bugfix: worker processes did not exit after reconfiguration and did not rotate logs if the eventport method was used. *) Bugfix: a worker process may got caught in an endless loop, if the "ip_hash" directive was used. *) Bugfix: now nginx does not log some alerts if eventport or /dev/poll methods are used.
author Igor Sysoev <http://sysoev.ru>
date Mon, 19 Mar 2007 00:00:00 +0300
parents 704622b2528a
children 390b8f8309d6
comparison
equal deleted inserted replaced
289:a9323c9433a7 290:f745bf973510
452 continue; 452 continue;
453 } 453 }
454 454
455 if (ch.command) { 455 if (ch.command) {
456 if (ngx_write_channel(ngx_processes[i].channel[0], 456 if (ngx_write_channel(ngx_processes[i].channel[0],
457 &ch, sizeof(ngx_channel_t), cycle->log) == NGX_OK) 457 &ch, sizeof(ngx_channel_t), cycle->log)
458 == NGX_OK)
458 { 459 {
459 if (signo != ngx_signal_value(NGX_REOPEN_SIGNAL)) { 460 if (signo != ngx_signal_value(NGX_REOPEN_SIGNAL)) {
460 ngx_processes[i].exiting = 1; 461 ngx_processes[i].exiting = 1;
461 } 462 }
462 463
661 662
662 663
663 static void 664 static void
664 ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) 665 ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
665 { 666 {
667 ngx_uint_t i;
668 ngx_connection_t *c;
666 #if (NGX_THREADS) 669 #if (NGX_THREADS)
667 ngx_int_t n; 670 ngx_int_t n;
668 ngx_err_t err; 671 ngx_err_t err;
669 ngx_core_conf_t *ccf; 672 ngx_core_conf_t *ccf;
670 #endif 673 #endif
676 #if (NGX_THREADS) 679 #if (NGX_THREADS)
677 680
678 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); 681 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
679 682
680 if (ngx_threads_n) { 683 if (ngx_threads_n) {
681 if (ngx_init_threads(ngx_threads_n, 684 if (ngx_init_threads(ngx_threads_n, ccf->thread_stack_size, cycle)
682 ccf->thread_stack_size, cycle) == NGX_ERROR) 685 == NGX_ERROR)
683 { 686 {
684 /* fatal */ 687 /* fatal */
685 exit(2); 688 exit(2);
686 } 689 }
687 690
702 exit(2); 705 exit(2);
703 } 706 }
704 707
705 if (ngx_create_thread((ngx_tid_t *) &ngx_threads[n].tid, 708 if (ngx_create_thread((ngx_tid_t *) &ngx_threads[n].tid,
706 ngx_worker_thread_cycle, 709 ngx_worker_thread_cycle,
707 (void *) &ngx_threads[n], cycle->log) != 0) 710 (void *) &ngx_threads[n], cycle->log)
711 != 0)
708 { 712 {
709 /* fatal */ 713 /* fatal */
710 exit(2); 714 exit(2);
711 } 715 }
712 } 716 }
713 } 717 }
714 718
715 #endif 719 #endif
716 720
717 for ( ;; ) { 721 for ( ;; ) {
718 if (ngx_exiting 722
719 && ngx_event_timer_rbtree.root == ngx_event_timer_rbtree.sentinel) 723 if (ngx_exiting) {
720 { 724
721 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting"); 725 c = cycle->connections;
722 726
723 ngx_worker_process_exit(cycle); 727 for (i = 0; i < cycle->connection_n; i++) {
728
729 /* THREAD: lock */
730
731 if (c[i].fd != -1 && c[i].idle) {
732 c[i].close = 1;
733 c[i].read->handler(c[i].read);
734 }
735 }
736
737 if (ngx_event_timer_rbtree.root == ngx_event_timer_rbtree.sentinel)
738 {
739 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
740
741 ngx_worker_process_exit(cycle);
742 }
724 } 743 }
725 744
726 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle"); 745 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
727 746
728 ngx_process_events_and_timers(cycle); 747 ngx_process_events_and_timers(cycle);
926 #if 0 945 #if 0
927 ngx_last_process = 0; 946 ngx_last_process = 0;
928 #endif 947 #endif
929 948
930 if (ngx_add_channel_event(cycle, ngx_channel, NGX_READ_EVENT, 949 if (ngx_add_channel_event(cycle, ngx_channel, NGX_READ_EVENT,
931 ngx_channel_handler) == NGX_ERROR) 950 ngx_channel_handler)
951 == NGX_ERROR)
932 { 952 {
933 /* fatal */ 953 /* fatal */
934 exit(2); 954 exit(2);
935 } 955 }
936 } 956 }
1022 } 1042 }
1023 1043
1024 return; 1044 return;
1025 } 1045 }
1026 1046
1047 if (ngx_event_flags & NGX_USE_EVENTPORT_EVENT) {
1048 if (ngx_add_event(ev, NGX_READ_EVENT, 0) == NGX_ERROR) {
1049 return;
1050 }
1051 }
1052
1027 if (n == NGX_AGAIN) { 1053 if (n == NGX_AGAIN) {
1028 return; 1054 return;
1029 } 1055 }
1030 1056
1031 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, 1057 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0,