summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorcashmere <cashmere@autistici.org>2026-06-22 20:10:53 +0200
committercashmere <cashmere@autistici.org>2026-06-22 20:10:53 +0200
commitd6eee110abe771c3586d8dc63fc8191c1c39474a (patch)
tree746f1af6986f711e5a52e66a1bf4c19d70a2b804 /src/main.c
parent52228bb5cb9fe79260e4bcab404390e9fec7b7ee (diff)
downloadtelnet-d6eee110abe771c3586d8dc63fc8191c1c39474a.tar.gz
src/main.c: better close conn and clean up
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index bc91977..f879c54 100644
--- a/src/main.c
+++ b/src/main.c
@@ -61,6 +61,9 @@ int main() {
if (n <= 0) {
/* close the connection if client disappeared or disconnected */
close(fds[i].fd);
+ fds[i] = fds[nfds - 1]; /* move back last slot */
+ nfds--; /* size down the current aray */
+ i--;
} else {
/* send every n bytes to the other clients */
for (nfds_t j = 1; j < nfds; j++) {