From: Sergey Kandaurov Date: Fri, 8 May 2026 11:32:41 +0000 (+0400) Subject: Split clients: improved calculation of range boundaries X-Git-Tag: release-1.31.2~15 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=d994f5b8220847eb8f7e4400be5f7e6eb4538e46;p=nginx.git Split clients: improved calculation of range boundaries If the last variant was given an explicit percentage to reach 100%, it did not cover hash values on the range boundary or due to accumulating rounding error. Now this corresponds to the configuration with "*". --- diff --git a/src/http/modules/ngx_http_split_clients_module.c b/src/http/modules/ngx_http_split_clients_module.c index 2f92c9e1a..c25bb0f42 100644 --- a/src/http/modules/ngx_http_split_clients_module.c +++ b/src/http/modules/ngx_http_split_clients_module.c @@ -182,6 +182,11 @@ ngx_conf_split_clients_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) for (i = 0; i < ctx->parts.nelts; i++) { sum = part[i].percent ? sum + part[i].percent : 10000; + + if (sum == 10000) { + part[i].percent = 0; + } + if (sum > 10000) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "percent total is greater than 100%%"); diff --git a/src/stream/ngx_stream_split_clients_module.c b/src/stream/ngx_stream_split_clients_module.c index af6c8a1b4..8cdc7b150 100644 --- a/src/stream/ngx_stream_split_clients_module.c +++ b/src/stream/ngx_stream_split_clients_module.c @@ -180,6 +180,11 @@ ngx_conf_split_clients_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) for (i = 0; i < ctx->parts.nelts; i++) { sum = part[i].percent ? sum + part[i].percent : 10000; + + if (sum == 10000) { + part[i].percent = 0; + } + if (sum > 10000) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "percent total is greater than 100%%");