close sockets/fds on disconnect and prevent fd leaks - teed - A multiplex relay… | |
git clone git://bitreich.org/teed git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
LICENSE | |
--- | |
commit c9671740957f58aa168262f3e76ad2f72542f05b | |
parent 22ed6e7883ecd3f6e3ade985a0963604ba800ade | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Mon, 14 Aug 2023 14:23:53 +0200 | |
close sockets/fds on disconnect and prevent fd leaks | |
Signed-off-by: Christoph Lohmann <[email protected]> | |
Diffstat: | |
M teed.c | 2 ++ | |
1 file changed, 2 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/teed.c b/teed.c | |
@@ -265,6 +265,7 @@ main(int argc, char *argv[]) | |
recvl = read(*(int *)e->data, recvbuf, | |
sizeof(recvbuf)); | |
if (recvl <= 0) { | |
+ close(*(int *)e->data); | |
e = llist_del(&rfds, e); | |
if (e == NULL) | |
break; | |
@@ -275,6 +276,7 @@ main(int argc, char *argv[]) | |
sendl = recvl; | |
while (sendl > 0) { | |
if ((sent = write(*(int *)qe->… | |
+ close(*(int *)qe->data… | |
qe = llist_del(&wfds, … | |
break; | |
} |