]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Fix] upstream: fix stale heap_idx in token bucket
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 6 Feb 2026 09:25:17 +0000 (09:25 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 6 Feb 2026 09:25:17 +0000 (09:25 +0000)
commit61bed05c2c384ef8b3976bf8d43e9ecc725a1f9b
tree22844bbb3ce67ede0f2ea259dee387d2a3b9ec49
parent87098841c8745c6f5b371f8d1bb8f644723dd6a9
[Fix] upstream: fix stale heap_idx in token bucket

The intrusive heap swaps entire structs during swim/sink, making
up->heap_idx stale after any heap modification. The update function
would silently skip updates when the cached index pointed to a
different upstream, breaking load distribution across backends.

Fix by falling back to linear search on cache miss and refreshing
heap_idx after every heap update. Also add underflow warning for
double-return detection and improve API documentation.
src/libutil/upstream.c
src/libutil/upstream.h