MEDIUM: pools: use a single pool_gc() function for locked and lockless

Locked and lockless shared pools don't need to use a different pool_gc()
function because this function isolates itself during the operation, so
we do not need to rely on DWCAS nor any atomic operation in fact. Let's
just get rid of the lockless one in favor of the simple one. This should
even result in a faster execution.

The ifdefs were slightly moved so that we can have pool_gc() defined
as soon as there are global pools, this avoids duplicating the function.

(cherry picked from commit 9b3ed51371693f70bab07e09cdd34e26e3a46d93)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit a206cf93eb17e2d0f8184b91a0775ada763e7f71)
[wt: for 2.3, this was simplified, only the lockless version was
 reworked to work without the DWCAS, very similarly to the one in
 2.4 except that accounting still has to be done]
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/src/pool.c b/src/pool.c
index 22522a5..c9974a2 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -342,21 +342,14 @@
 		thread_isolate();
 
 	list_for_each_entry(entry, &pools, list) {
-		while ((int)((volatile int)entry->allocated - (volatile int)entry->used) > (int)entry->minavail) {
-			struct pool_free_list cmp, new;
-
-			cmp.seq = entry->seq;
-			__ha_barrier_load();
-			cmp.free_list = entry->free_list;
-			__ha_barrier_load();
-			if (cmp.free_list == NULL)
-				break;
-			new.free_list = *POOL_LINK(entry, cmp.free_list);
-			new.seq = cmp.seq + 1;
-			if (HA_ATOMIC_DWCAS(&entry->free_list, &cmp, &new) == 0)
-				continue;
-			pool_free_area(cmp.free_list, entry->size + POOL_EXTRA);
-			_HA_ATOMIC_SUB(&entry->allocated, 1);
+		void *temp;
+		//qfprintf(stderr, "Flushing pool %s\n", entry->name);
+		while (entry->free_list &&
+		       (int)(entry->allocated - entry->used) > (int)entry->minavail) {
+			temp = entry->free_list;
+			entry->free_list = *POOL_LINK(entry, temp);
+			entry->allocated--;
+			pool_free_area(temp, entry->size + POOL_EXTRA);
 		}
 	}