}
+void
+ngx_close_idle_connections(ngx_cycle_t *cycle)
+{
+ ngx_uint_t i;
+ ngx_connection_t *c;
+
+ 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);
+ }
+ }
+}
+
+
ngx_int_t
ngx_connection_local_sockaddr(ngx_connection_t *c, ngx_str_t *s,
ngx_uint_t port)
void ngx_configure_listening_sockets(ngx_cycle_t *cycle);
void ngx_close_listening_sockets(ngx_cycle_t *cycle);
void ngx_close_connection(ngx_connection_t *c);
+void ngx_close_idle_connections(ngx_cycle_t *cycle);
ngx_int_t ngx_connection_local_sockaddr(ngx_connection_t *c, ngx_str_t *s,
ngx_uint_t port);
ngx_int_t ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text);
goto invalid;
}
+ if (ngx_terminate || ngx_exiting) {
+ goto invalid;
+ }
+
if (ngx_handle_read_event(c->read, 0) != NGX_OK) {
goto invalid;
}
{
ngx_int_t worker = (intptr_t) data;
- ngx_uint_t i;
- ngx_connection_t *c;
-
ngx_process = NGX_PROCESS_WORKER;
ngx_worker = worker;
for ( ;; ) {
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);
- }
- }
-
ngx_event_cancel_timers();
if (ngx_event_timer_rbtree.root == ngx_event_timer_rbtree.sentinel)
ngx_setproctitle("worker process is shutting down");
if (!ngx_exiting) {
- ngx_close_listening_sockets(cycle);
ngx_exiting = 1;
+ ngx_close_listening_sockets(cycle);
+ ngx_close_idle_connections(cycle);
}
}
static ngx_thread_value_t __stdcall
ngx_worker_thread(void *data)
{
- ngx_int_t n;
- ngx_uint_t i;
- ngx_cycle_t *cycle;
- ngx_connection_t *c;
+ ngx_int_t n;
+ ngx_cycle_t *cycle;
cycle = (ngx_cycle_t *) ngx_cycle;
while (!ngx_quit) {
if (ngx_exiting) {
-
- c = cycle->connections;
-
- for (i = 0; i < cycle->connection_n; i++) {
-
- /* THREAD: lock */
-
- if (c[i].fd != (ngx_socket_t) -1 && c[i].idle) {
- c[i].close = 1;
- c[i].read->handler(c[i].read);
- }
- }
-
ngx_event_cancel_timers();
if (ngx_event_timer_rbtree.root
ngx_quit = 0;
if (!ngx_exiting) {
- ngx_close_listening_sockets(cycle);
ngx_exiting = 1;
+ ngx_close_listening_sockets(cycle);
+ ngx_close_idle_connections(cycle);
}
}