comparison src/os/unix/ngx_process_cycle.c @ 1135:03f1133f24e8

close keep-alive connections in the shuting down processes
author Igor Sysoev <igor@sysoev.ru>
date Mon, 19 Mar 2007 13:20:15 +0000
parents 384c92c210f9
children df2592d32e49
comparison
equal deleted inserted replaced
1134:384c92c210f9 1135:03f1133f24e8
662 662
663 663
664 static void 664 static void
665 ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) 665 ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
666 { 666 {
667 ngx_uint_t i;
668 ngx_connection_t *c;
667 #if (NGX_THREADS) 669 #if (NGX_THREADS)
668 ngx_int_t n; 670 ngx_int_t n;
669 ngx_err_t err; 671 ngx_err_t err;
670 ngx_core_conf_t *ccf; 672 ngx_core_conf_t *ccf;
671 #endif 673 #endif
715 } 717 }
716 718
717 #endif 719 #endif
718 720
719 for ( ;; ) { 721 for ( ;; ) {
720 if (ngx_exiting 722
721 && ngx_event_timer_rbtree.root == ngx_event_timer_rbtree.sentinel) 723 if (ngx_exiting) {
722 { 724
723 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting"); 725 c = cycle->connections;
724 726
725 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 }
726 } 743 }
727 744
728 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");
729 746
730 ngx_process_events_and_timers(cycle); 747 ngx_process_events_and_timers(cycle);