BUG/MINOR: init/threads: continue to limit default thread count to max per group

Jakub Vojacek reported in issue #1955 that haproxy 2.7.0 doesn't start
anymore on a 128-CPU machine with a default config. The reason is the
raise of the default MAX_THREADS value that came with thread groups.
Previously, the maximum number of threads was simply limited to this
value, and all of them fit into one group. Now the limit being higher,
all threads cannot fit by default into a single group, and haproxy fails
to start.

The solution adopted here is to continue to limit the number of threads
to the max supported per group, but to multiply it by the number of groups
(usually 1 by default). In addition, a diag warning is now emitted when
this happens, reminding the user to set nbthread or adjust thread-groups.
We can hardly do more than a diag warning if we don't want to make the
upgrade painful for users.

Thanks to Jakub for reporting this early. This must be backported to 2.7.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 2410cee..ac98a95 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -2797,6 +2797,16 @@
 #endif
 			global.nbthread = numa_cores ? numa_cores :
 			                               thread_cpus_enabled_at_boot;
+
+			/* Note that we cannot have more than 32 or 64 threads per group */
+			if (!global.nbtgroups)
+				global.nbtgroups = 1;
+
+			if (global.nbthread > MAX_THREADS_PER_GROUP * global.nbtgroups) {
+				ha_diag_warning("nbthread not set, found %d CPUs, limiting to %d threads (maximum is %d per thread group). Please set nbthreads and/or increase thread-groups in the global section to silence this warning.\n",
+					   global.nbthread, MAX_THREADS_PER_GROUP * global.nbtgroups, MAX_THREADS_PER_GROUP);
+				global.nbthread = MAX_THREADS_PER_GROUP * global.nbtgroups;
+			}
 		}
 #endif
 	}