commit f56227b6e7b21c76f910ad384ee793c08f20ed54 from: Omar Polo date: Wed Jul 06 12:46:58 2022 UTC move accounting after the connection was accepted otherwise we may end up in a weird state where we're counting connections that we don't have or have cleared a timeout without a reason. commit - 0828da2ca72a11090a29c8f94930781558e611c3 commit + f56227b6e7b21c76f910ad384ee793c08f20ed54 blob - 5feaeb798249d22fa5a82b0612d41338208e18b3 blob + 4e4ecbf9ec80c874ee3acfb1454ef4a716f1745d --- lstun.c +++ lstun.c @@ -291,16 +291,11 @@ do_accept(int fd, short event, void *data) log_debug("incoming connection"); - if (evtimer_pending(&timeoutev, NULL)) - evtimer_del(&timeoutev); - if ((s = accept(fd, NULL, 0)) == -1) { log_warn("accept"); return; } - conn++; - if (ssh_pid == -1 && spawn_ssh() == -1) { close(s); return; @@ -312,6 +307,10 @@ do_accept(int fd, short event, void *data) return; } + conn++; + if (evtimer_pending(&timeoutev, NULL)) + evtimer_del(&timeoutev); + c->source = s; c->to = -1; c->retry.tv_sec = BACKOFF;