Klaus Demo nginx / 52fcfd0
Fixed calculation of range boundaries. Ruslan Ermilov 10 years ago
1 changed file(s) with 9 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
9696 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
9797 "http split: %uD %uD", hash, part[i].percent);
9898
99 if (hash < part[i].percent) {
99 if (hash < part[i].percent || part[i].percent == 0) {
100100 *v = part[i].value;
101101 return NGX_OK;
102102 }
110110 ngx_conf_split_clients_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
111111 {
112112 char *rv;
113 uint32_t sum, last;
113114 ngx_str_t *value, name;
114 ngx_uint_t i, sum, last;
115 ngx_uint_t i;
115116 ngx_conf_t save;
116117 ngx_http_variable_t *var;
117118 ngx_http_split_clients_ctx_t *ctx;
174175 for (i = 0; i < ctx->parts.nelts; i++) {
175176 sum = part[i].percent ? sum + part[i].percent : 10000;
176177 if (sum > 10000) {
177 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
178 "percent sum is more than 100%%");
179 return NGX_CONF_ERROR;
178 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
179 "percent sum is more than 100%%");
180 return NGX_CONF_ERROR;
180181 }
181182
182183 if (part[i].percent) {
183 part[i].percent = (uint32_t)
184 (last + 0xffffffff / 10000 * part[i].percent);
185 } else {
186 part[i].percent = 0xffffffff;
187 }
188
189 last = part[i].percent;
184 last += part[i].percent * (uint64_t) 0xffffffff / 10000;
185 part[i].percent = last;
186 }
190187 }
191188
192189 return rv;