MINOR: pools/debug: slightly relax DEBUG_DONT_SHARE_POOLS

The purpose of this debugging option was to prevent certain pools from
masking other ones when they were shared. For example, task, http_txn,
h2s, h1s, h1c, session, fcgi_strm, and connection are all 192 bytes and
would normally be mergedi, but not with this option. The problem is that
certain pools are declared multiple times with various parameters, which
are often very close, and due to the way the option works, they're not
shared either. Good examples of this are captures and stick tables. Some
configurations have large numbers of stick-tables of pretty similar types
and it's very common to end up with the following when the option is
enabled:

  $ socat - /tmp/sock1  <<< "show pools" | grep stick
    - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753800=56
    - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753880=57
    - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753900=58
    - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753980=59
    - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753a00=60
    - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753a80=61
    - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753b00=62
    - Pool sticktables (224 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753780=55

In addition to not being convenient, it can have important effects on the
memory usage because these pools will not share their entries, so one stick
table cannot allocate from another one's pool.

This patch solves this by going back to the initial goal which was not to
have different pools in the same list. Instead of masking the MAP_F_SHARED
flag, it simply adds a test on the pool's name, and disables pool sharing
if the names differ. This way pools are not shared unless they're of the
same name and size, which doesn't hinder debugging. The same test above
now returns this:

  $ socat - /tmp/sock1  <<< "show pools" | grep stick
    - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 7 users, @0x3fadb30 [SHARED]
    - Pool sticktables (224 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x3facaa0 [SHARED]

This is much better. This should probably be backported, in order to limit
the side effects of DEBUG_DONT_SHARE_POOLS being enabled in production.

(cherry picked from commit 1ab6c0bfd2b8e178d78955e5a8279fe04ac45da1)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 0b15516a5c263730df7fa872c1c4972c7c6ed74d)
[wt: adjust ctx in pool-t.h]
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 95085827ff7be515358dcc84896d00da117ad0a1)
[wt: pool-t.h is in memory.h]
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/include/common/memory.h b/include/common/memory.h
index 98f9db2..74d9205 100644
--- a/include/common/memory.h
+++ b/include/common/memory.h
@@ -34,11 +34,7 @@
 #include <common/hathreads.h>
 #include <common/initcall.h>
 
-#ifndef DEBUG_DONT_SHARE_POOLS
 #define MEM_F_SHARED	0x1
-#else
-#define MEM_F_SHARED	0
-#endif
 #define MEM_F_EXACT	0x2
 
 /* reserve an extra void* at the end of a pool for linking */
diff --git a/src/memory.c b/src/memory.c
index 6ef9f61..126d534 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -94,7 +94,11 @@
 			 * we look for a sharable one or for the next position
 			 * before which we will insert a new one.
 			 */
-			if (flags & entry->flags & MEM_F_SHARED) {
+			if ((flags & entry->flags & MEM_F_SHARED)
+#ifdef DEBUG_DONT_SHARE_POOLS
+			    && strcmp(name, entry->name) == 0
+#endif
+			    ) {
 				/* we can share this one */
 				pool = entry;
 				DPRINTF(stderr, "Sharing %s with %s\n", name, pool->name);