]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pool: make pool_is_crowded() always true when no shared pools are used
authorWilly Tarreau <w@1wt.eu>
Sat, 1 Jan 2022 20:00:07 +0000 (21:00 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 2 Jan 2022 18:35:26 +0000 (19:35 +0100)
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.

include/haproxy/pool.h

index 2a6fa9d42788be58a54708b3cf2015afda11efce..1f9ca21f3193ac6d5820a36e46809e9211f1a23b 100644 (file)
@@ -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 <ptr> to pool <pool>, then update the pool used count.
  * Both the pool and the pointer must be valid. Use pool_free() for normal
  * operations.