comparison src/stream/ngx_stream_limit_conn_module.c @ 6693:3908156a51fa

Stream: phases.
author Roman Arutyunyan <arut@nginx.com>
date Thu, 15 Sep 2016 14:55:54 +0300
parents 8ed51b02f655
children 359b0ea2b067
comparison
equal deleted inserted replaced
6692:56fc55e32f23 6693:3908156a51fa
176 node = ngx_slab_alloc_locked(shpool, n); 176 node = ngx_slab_alloc_locked(shpool, n);
177 177
178 if (node == NULL) { 178 if (node == NULL) {
179 ngx_shmtx_unlock(&shpool->mutex); 179 ngx_shmtx_unlock(&shpool->mutex);
180 ngx_stream_limit_conn_cleanup_all(s->connection->pool); 180 ngx_stream_limit_conn_cleanup_all(s->connection->pool);
181 return NGX_ABORT; 181 return NGX_STREAM_SERVICE_UNAVAILABLE;
182 } 182 }
183 183
184 lc = (ngx_stream_limit_conn_node_t *) &node->color; 184 lc = (ngx_stream_limit_conn_node_t *) &node->color;
185 185
186 node->key = hash; 186 node->key = hash;
201 ngx_log_error(lccf->log_level, s->connection->log, 0, 201 ngx_log_error(lccf->log_level, s->connection->log, 0,
202 "limiting connections by zone \"%V\"", 202 "limiting connections by zone \"%V\"",
203 &limits[i].shm_zone->shm.name); 203 &limits[i].shm_zone->shm.name);
204 204
205 ngx_stream_limit_conn_cleanup_all(s->connection->pool); 205 ngx_stream_limit_conn_cleanup_all(s->connection->pool);
206 return NGX_ABORT; 206 return NGX_STREAM_SERVICE_UNAVAILABLE;
207 } 207 }
208 208
209 lc->conn++; 209 lc->conn++;
210 } 210 }
211 211
628 628
629 629
630 static ngx_int_t 630 static ngx_int_t
631 ngx_stream_limit_conn_init(ngx_conf_t *cf) 631 ngx_stream_limit_conn_init(ngx_conf_t *cf)
632 { 632 {
633 ngx_stream_handler_pt *h;
633 ngx_stream_core_main_conf_t *cmcf; 634 ngx_stream_core_main_conf_t *cmcf;
634 635
635 cmcf = ngx_stream_conf_get_module_main_conf(cf, ngx_stream_core_module); 636 cmcf = ngx_stream_conf_get_module_main_conf(cf, ngx_stream_core_module);
636 637
637 cmcf->limit_conn_handler = ngx_stream_limit_conn_handler; 638 h = ngx_array_push(&cmcf->phases[NGX_STREAM_PREACCESS_PHASE].handlers);
639 if (h == NULL) {
640 return NGX_ERROR;
641 }
642
643 *h = ngx_stream_limit_conn_handler;
638 644
639 return NGX_OK; 645 return NGX_OK;
640 } 646 }