From 284f55754ece406739aa5a439157545ce9873c5f Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Fri, 8 May 2026 15:32:41 +0400 Subject: [PATCH] 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 "*". --- src/http/modules/ngx_http_split_clients_module.c | 5 +++++ src/stream/ngx_stream_split_clients_module.c | 5 +++++ 2 files changed, 10 insertions(+) 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%%");