]> git.kaiwu.me - nginx.git/commitdiff
Split clients: improved calculation of range boundaries
authorSergey Kandaurov <pluknet@nginx.com>
Fri, 8 May 2026 11:32:41 +0000 (15:32 +0400)
committerSergey Kandaurov <s.kandaurov@f5.com>
Tue, 9 Jun 2026 15:04:17 +0000 (19:04 +0400)
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
src/stream/ngx_stream_split_clients_module.c

index 2f92c9e1a8fc153bb95bf8744b61978c0ef0e2d3..c25bb0f425fac23d6896581c9a6a3b748e4a507e 100644 (file)
@@ -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%%");
index af6c8a1b466df5d7246da2cd7e78efaacee50365..8cdc7b150cddbff8bd99c910e7bda7d6bb2ca895 100644 (file)
@@ -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%%");