summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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++) {