gods

a simple blocklist for ssh
Log | Files | Refs | README | LICENSE

commit edf5388bf7f0707b933be24329ba06671d25ab90
parent f39f3abeb3102d20a78a7afcd8c50db535ba6de2
Author: Naveen Narayanan <zerous@nocebo.space>
Date:   Wed, 20 Oct 2021 02:03:34 +0200

Fix bug

Remove while loop as it loops until readline() gets new data. This
eventuates in unban() being called only when new data arrives.

unban() should be called at the beginning of the loop to ensure that
it is called on every iteration of the for loop.

Diffstat:
Mmain.c | 7+++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/main.c b/main.c @@ -206,8 +206,9 @@ main(int argc, char **argv) now = time(NULL); for ( ; ; ) { - while ((line = readline(fd)) == NULL) { - usleep(500000); + unban(NULL, &head); + if ((line = readline(fd)) == NULL) { + usleep(5); continue; } @@ -244,8 +245,6 @@ main(int argc, char **argv) SLIST_REMOVE(&head, a, attacker, attackers); free(a); } - - unban(NULL, &head); } cleanup(); return 0;