r->http_state = NGX_HTTP_KEEPALIVE_STATE;
#endif
+ c->idle = 1;
+
if (rev->ready) {
ngx_http_keepalive_handler(rev);
}
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http keepalive handler");
- if (rev->timedout) {
+ if (rev->timedout || c->close) {
ngx_http_close_connection(c);
return;
}
c->log->handler = ngx_http_log_error;
c->log->action = "reading client request line";
+ c->idle = 0;
+
ngx_http_init_request(rev);
}
static void
ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
{
+ ngx_uint_t i;
+ ngx_connection_t *c;
#if (NGX_THREADS)
ngx_int_t n;
ngx_err_t err;
#endif
for ( ;; ) {
- if (ngx_exiting
- && ngx_event_timer_rbtree.root == ngx_event_timer_rbtree.sentinel)
- {
- ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
- ngx_worker_process_exit(cycle);
+ if (ngx_exiting) {
+
+ c = cycle->connections;
+
+ for (i = 0; i < cycle->connection_n; i++) {
+
+ /* THREAD: lock */
+
+ if (c[i].fd != -1 && c[i].idle) {
+ c[i].close = 1;
+ c[i].read->handler(c[i].read);
+ }
+ }
+
+ if (ngx_event_timer_rbtree.root == ngx_event_timer_rbtree.sentinel)
+ {
+ ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
+
+ ngx_worker_process_exit(cycle);
+ }
}
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");