From: Willy Tarreau Date: Sat, 1 Jan 2022 20:00:07 +0000 (+0100) Subject: MINOR: pool: make pool_is_crowded() always true when no shared pools are used X-Git-Tag: v2.6-dev1~200 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a06f78b37698151f5106d8755230d3fc8c47bd09;p=thirdparty%2Fhaproxy.git MINOR: pool: make pool_is_crowded() always true when no shared pools are used This function is used to know whether the shared pools are full or if we can store more objects in them. Right now it cannot be used in a generic way because when shared pools are not used it will return false, letting one think pools can accept objects. Let's make one variant for each build model. --- diff --git a/include/haproxy/pool.h b/include/haproxy/pool.h index 2a6fa9d427..1f9ca21f31 100644 --- a/include/haproxy/pool.h +++ b/include/haproxy/pool.h @@ -110,16 +110,14 @@ void pool_evict_from_local_cache(struct pool_head *pool); void pool_evict_from_local_caches(void); void pool_put_to_cache(struct pool_head *pool, void *ptr); -/* returns true if the pool is considered to have too many free objects */ +#if defined(CONFIG_HAP_NO_GLOBAL_POOLS) + static inline int pool_is_crowded(const struct pool_head *pool) { - return pool->allocated >= swrate_avg(pool->needed_avg + pool->needed_avg / 4, POOL_AVG_SAMPLES) && - (int)(pool->allocated - pool->used) >= pool->minavail; + /* no shared pools, hence they're always full */ + return 1; } - -#if defined(CONFIG_HAP_NO_GLOBAL_POOLS) - static inline void pool_refill_local_from_shared(struct pool_head *pool, struct pool_cache_head *pch) { /* ignored without shared pools */ @@ -134,6 +132,13 @@ static inline void pool_put_to_shared_cache(struct pool_head *pool, void *ptr) void pool_refill_local_from_shared(struct pool_head *pool, struct pool_cache_head *pch); +/* returns true if the pool is considered to have too many free objects */ +static inline int pool_is_crowded(const struct pool_head *pool) +{ + return pool->allocated >= swrate_avg(pool->needed_avg + pool->needed_avg / 4, POOL_AVG_SAMPLES) && + (int)(pool->allocated - pool->used) >= pool->minavail; +} + /* Locklessly add item to pool , then update the pool used count. * Both the pool and the pointer must be valid. Use pool_free() for normal * operations.