31 static ngx_int_t ngx_http_upstream_get_least_conn_peer(
35 static void *ngx_http_upstream_least_conn_create_conf(
ngx_conf_t *cf);
40 static ngx_command_t ngx_http_upstream_least_conn_commands[] = {
44 ngx_http_upstream_least_conn,
60 ngx_http_upstream_least_conn_create_conf,
70 &ngx_http_upstream_least_conn_module_ctx,
71 ngx_http_upstream_least_conn_commands,
85 ngx_http_upstream_init_least_conn(
ngx_conf_t *cf,
108 ngx_http_upstream_least_conn_module);
111 if (lcf->
conns == NULL) {
115 us->
peer.
init = ngx_http_upstream_init_least_conn_peer;
129 "init least conn peer");
132 ngx_http_upstream_least_conn_module);
170 "get least conn peer, try: %ui", pc->
tries);
186 #if (NGX_SUPPRESS_WARN)
191 for (i = 0; i < peers->
number; i++) {
193 n = i / (8 *
sizeof(uintptr_t));
194 m = (uintptr_t) 1 << i % (8 *
sizeof(uintptr_t));
200 peer = &peers->
peer[
i];
235 "get least conn peer, no peer found");
242 "get least conn peer, many");
244 for (i = p; i < peers->
number; i++) {
246 n = i / (8 *
sizeof(uintptr_t));
247 m = (uintptr_t) 1 << i % (8 *
sizeof(uintptr_t));
253 peer = &peers->
peer[
i];
296 n = p / (8 *
sizeof(uintptr_t));
297 m = (uintptr_t) 1 << p % (8 *
sizeof(uintptr_t));
312 "get least conn peer, backup servers");
320 / (8 *
sizeof(uintptr_t));
322 for (i = 0; i < n; i++) {
326 rc = ngx_http_upstream_get_least_conn_peer(pc, lcp);
335 for (i = 0; i < peers->
number; i++) {
352 "free least conn peer %ui %ui", pc->
tries, state);
366 ngx_http_upstream_least_conn_create_conf(
ngx_conf_t *cf)
395 "load balancing method redefined");