Klaus Demo nginx / 4ddeff4
close keep-alive connections in the shuting down processes Igor Sysoev 15 years ago
3 changed file(s) with 31 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
142142 unsigned error:1;
143143 unsigned destroyed:1;
144144
145 unsigned idle:1;
146 unsigned close:1;
147
145148 unsigned sendfile:1;
146149 unsigned sndlowat:1;
147150 unsigned tcp_nodelay:2; /* ngx_connection_tcp_nodelay_e */
20312031 r->http_state = NGX_HTTP_KEEPALIVE_STATE;
20322032 #endif
20332033
2034 c->idle = 1;
2035
20342036 if (rev->ready) {
20352037 ngx_http_keepalive_handler(rev);
20362038 }
20492051
20502052 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http keepalive handler");
20512053
2052 if (rev->timedout) {
2054 if (rev->timedout || c->close) {
20532055 ngx_http_close_connection(c);
20542056 return;
20552057 }
21382140 c->log->handler = ngx_http_log_error;
21392141 c->log->action = "reading client request line";
21402142
2143 c->idle = 0;
2144
21412145 ngx_http_init_request(rev);
21422146 }
21432147
663663 static void
664664 ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
665665 {
666 ngx_uint_t i;
667 ngx_connection_t *c;
666668 #if (NGX_THREADS)
667669 ngx_int_t n;
668670 ngx_err_t err;
716718 #endif
717719
718720 for ( ;; ) {
719 if (ngx_exiting
720 && ngx_event_timer_rbtree.root == ngx_event_timer_rbtree.sentinel)
721 {
722 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
723
724 ngx_worker_process_exit(cycle);
721
722 if (ngx_exiting) {
723
724 c = cycle->connections;
725
726 for (i = 0; i < cycle->connection_n; i++) {
727
728 /* THREAD: lock */
729
730 if (c[i].fd != -1 && c[i].idle) {
731 c[i].close = 1;
732 c[i].read->handler(c[i].read);
733 }
734 }
735
736 if (ngx_event_timer_rbtree.root == ngx_event_timer_rbtree.sentinel)
737 {
738 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
739
740 ngx_worker_process_exit(cycle);
741 }
725742 }
726743
727744 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");