MINOR: tinfo: make thread_set functions return nth group/mask instead of first

thread_set_first_group() and thread_set_first_tmask() were modified
and renamed to instead return the number and mask of the nth group.
Passing zero continues to return the first one, but it will be more
convenient to use this way when building shards.
diff --git a/include/haproxy/tinfo.h b/include/haproxy/tinfo.h
index 4bae4f2..3d10560 100644
--- a/include/haproxy/tinfo.h
+++ b/include/haproxy/tinfo.h
@@ -68,33 +68,36 @@
 	return 1;
 }
 
-/* returns the number starting at 1 of the first thread-group set in thread set
+/* returns the number starting at 1 of the <n>th thread-group set in thread set
  * <ts>, or zero if the set is empty or if thread numbers are only absolute.
+ * <n> starts at zero and corresponds to the number of non-empty groups to be
+ * skipped (i.e. 0 returns the first one).
  */
-static inline int thread_set_first_group(const struct thread_set *ts)
+static inline int thread_set_nth_group(const struct thread_set *ts, int n)
 {
 	int i;
 
 	if (ts->nbgrp) {
 		for (i = 0; i < MAX_TGROUPS; i++)
-			if (ts->rel[i])
+			if (ts->rel[i] && !n--)
 				return i + 1;
 	}
 	return 0;
 }
 
-/* returns the thread mask of the first assigned thread-group in the thread
+/* returns the thread mask of the <n>th assigned thread-group in the thread
  * set <ts> for relative sets, the first thread mask at all in case of absolute
  * sets, or zero if the set is empty. This is only used temporarily to ease the
- * transition.
+ * transition. <n> starts at zero and corresponds to the number of non-empty
+ * groups to be skipped (i.e. 0 returns the first one).
  */
-static inline ulong thread_set_first_tmask(const struct thread_set *ts)
+static inline ulong thread_set_nth_tmask(const struct thread_set *ts, int n)
 {
 	int i;
 
 	if (ts->nbgrp) {
 		for (i = 0; i < MAX_TGROUPS; i++)
-			if (ts->rel[i])
+			if (ts->rel[i] && !n--)
 				return ts->rel[i];
 	}
 	return ts->abs[0];
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 06ee980..52f40d6 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -3016,8 +3016,8 @@
 					}
 
 					/* assign the first (and only) thread and group */
-					new_li->rx.bind_thread = thread_set_first_tmask(&new_ts);
-					new_li->rx.bind_tgroup = thread_set_first_group(&new_ts);
+					new_li->rx.bind_thread = thread_set_nth_tmask(&new_ts, 0);
+					new_li->rx.bind_tgroup = thread_set_nth_group(&new_ts, 0);
 					done -= todo;
 
 					shard++;
@@ -4458,8 +4458,8 @@
 
 					/* apply thread masks and groups to all receivers */
 					list_for_each_entry(li, &bind_conf->listeners, by_bind) {
-						li->rx.bind_thread = thread_set_first_tmask(&bind_conf->thread_set);
-						li->rx.bind_tgroup = thread_set_first_group(&bind_conf->thread_set);
+						li->rx.bind_thread = thread_set_nth_tmask(&bind_conf->thread_set, 0);
+						li->rx.bind_tgroup = thread_set_nth_group(&bind_conf->thread_set, 0);
 					}
 
 					if (bind_conf->xprt->prepare_bind_conf &&
diff --git a/src/thread.c b/src/thread.c
index 0deb920..af27bbb 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -1311,7 +1311,7 @@
 	}
 
 	/* update the thread_set */
-	if (!thread_set_first_group(&new_ts)) {
+	if (!thread_set_nth_group(&new_ts, 0)) {
 		memprintf(err, "'thread' directive only references non-existing threads");
 		return -1;
 	}