BUILD: listener: fix 'for' loop inline variable declaration

commit 16eb0fab3 ("MAJOR: counters: dispatch counters over thread groups")
introduced a build regression on some compilers:

  src/listener.c: In function 'listener_accept':
  src/listener.c:1095:3: error: 'for' loop initial declarations are only allowed in C99 mode
     for (int it = 0; it < global.nbtgroups; it++)
     ^
  src/listener.c:1095:3: note: use option -std=c99 or -std=gnu99 to compile your code
  src/listener.c:1101:4: error: 'for' loop initial declarations are only allowed in C99 mode
      for (int it = 0; it < global.nbtgroups; it++) {
      ^
  make: *** [src/listener.o] Error 1
  make: *** Waiting for unfinished jobs....

Let's fix that.
No backport needed
This commit is contained in:
Aurelien DARRAGON 2025-06-11 19:41:38 +02:00 committed by Christopher Faulet
parent 01f011faeb
commit b5067a972c

View File

@ -1091,14 +1091,15 @@ void listener_accept(struct listener *l)
#endif #endif
if (p && p->fe_sps_lim) { if (p && p->fe_sps_lim) {
int max = 0; int max = 0;
int it;
for (int it = 0; it < global.nbtgroups; it++) for (it = 0; it < global.nbtgroups; it++)
max += freq_ctr_remain(&p->fe_counters.shared->tg[it]->sess_per_sec, p->fe_sps_lim, 0); max += freq_ctr_remain(&p->fe_counters.shared->tg[it]->sess_per_sec, p->fe_sps_lim, 0);
if (unlikely(!max)) { if (unlikely(!max)) {
unsigned int min_wait = 0; unsigned int min_wait = 0;
for (int it = 0; it < global.nbtgroups; it++) { for (it = 0; it < global.nbtgroups; it++) {
unsigned int cur_wait = next_event_delay(&p->fe_counters.shared->tg[it]->sess_per_sec, p->fe_sps_lim, 0); unsigned int cur_wait = next_event_delay(&p->fe_counters.shared->tg[it]->sess_per_sec, p->fe_sps_lim, 0);
if (!it || cur_wait < min_wait) if (!it || cur_wait < min_wait)
min_wait = cur_wait; min_wait = cur_wait;