BUG/MEDIUM: listener: duplicate inherited FDs if needed

Since commit 36d9097cf ("MINOR: fd: Add BUG_ON checks on fd_insert()"),
there is currently a test in fd_insert() to detect that we're not trying
to reinsert an FD that had already been inserted. This test catches the
following anomalies:

   frontend fail1
       bind fd@0
       bind fd@0

and:

   frontend fail2
       bind fd@0 shards 2

What happens is that clone_listener() is called on a listener already
having an FD, and when sock_{inet,unix}_bind_receiver() are called, the
same FD will be registered multiple times and rightfully crash in the
sanity check.

It wouldn't be correct to block shards though (e.g. they could be used
in a default-bind line). What looks like a safer and more future-proof
approach simply is to dup() the FD so that each listener has one copy.
This is also the only solution that might allow later to support more
than 64 threads on an inherited FD.

This needs to be backported as far as 2.4. Better wait for at least
one extra -dev version before backporting though, as the bug should
not be triggered often anyway.

(cherry picked from commit 145b17fd2f6857e45ca184419f29f41343446fc5)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 2aa96f003af84fc68b89efdfb4d6f1866f13788a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit f1a031aca71dced4e66c36bf5878d2e976cbe9b0)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit d291b55abc8dec74b2839b4045d01222b87dd54d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
2 files changed