BUG/MEDIUM: debug: make the debug_handler check for the thread in threads_to_dump

It happens that just sending the debug signal to the process makes on
thread wait for its turn while nobody wants to dump. We need to at
least verify that a dump was really requested for this thread.

This can be backported to 2.1 and 2.0.

(cherry picked from commit 82aafc4a0fd5cf5a5203b37f622105a73fe5ba94)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 7bdbd36e049e3a728b5bff9dbd8478f4cd94ab71)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/src/debug.c b/src/debug.c
index cfb4690..f0cfdd1 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -476,6 +476,12 @@
 /* handles DEBUGSIG to dump the state of the thread it's working on */
 void debug_handler(int sig, siginfo_t *si, void *arg)
 {
+	/* first, let's check it's really for us and that we didn't just get
+	 * a spurious DEBUGSIG.
+	 */
+	if (!(threads_to_dump & tid_bit))
+		return;
+
 	/* There are 4 phases in the dump process:
 	 *   1- wait for our turn, i.e. when all lower bits are gone.
 	 *   2- perform the action if our bit is set